[java decompiler] better filter for synthetic constructor parameters

master
Roman Shevchenko 7 years ago
parent b3171e60c9
commit f83c480383
  1. 2
      src/org/jetbrains/java/decompiler/main/ClassWriter.java
  2. 1
      src/org/jetbrains/java/decompiler/main/ClassesProcessor.java
  3. 4
      src/org/jetbrains/java/decompiler/main/rels/NestedClassProcessor.java
  4. 12
      src/org/jetbrains/java/decompiler/modules/decompiler/exps/NewExprent.java

@ -227,7 +227,7 @@ public class ClassWriter {
for (ClassNode inner : node.nested) {
if (inner.type == ClassNode.CLASS_MEMBER) {
StructClass innerCl = inner.classStruct;
boolean isSynthetic = (inner.access & CodeConstants.ACC_SYNTHETIC) != 0 || innerCl.isSynthetic() || inner.namelessConstructorStub;
boolean isSynthetic = (inner.access & CodeConstants.ACC_SYNTHETIC) != 0 || innerCl.isSynthetic();
boolean hide = isSynthetic && DecompilerContext.getOption(IFernflowerPreferences.REMOVE_SYNTHETIC) ||
wrapper.getHiddenMembers().contains(innerCl.qualifiedName);
if (hide) continue;

@ -327,7 +327,6 @@ public class ClassesProcessor {
public final Set<String> enclosingClasses = new HashSet<>();
public ClassNode parent;
public LambdaInformation lambdaInformation;
public boolean namelessConstructorStub = false;
public ClassNode(String content_class_name,
String content_method_name,

@ -61,10 +61,6 @@ public class NestedClassProcessor {
DecompilerContext.getLogger().writeMessage(message, IFernflowerLogger.Severity.WARN);
child.simpleName = "NamelessClass_" + (++nameless);
}
child.namelessConstructorStub = !cl.hasModifier(CodeConstants.ACC_STATIC) && cl.getMethods().size() + cl.getFields().size() == 0;
}
else if (child.type == ClassNode.CLASS_ANONYMOUS && (child.access & CodeConstants.ACC_SYNTHETIC) != 0 || cl.isSynthetic()) {
child.namelessConstructorStub = !cl.hasModifier(CodeConstants.ACC_STATIC) && cl.getMethods().size() + cl.getFields().size() == 0;
}
}

@ -283,11 +283,8 @@ public class NewExprent extends Exprent {
Exprent expr = InvocationExprent.unboxIfNeeded(parameters.get(i));
VarType leftType = constructor.getDescriptor().params[i];
if (i == parameters.size() - 1 && expr.getExprType() == VarType.VARTYPE_NULL) {
ClassNode node = DecompilerContext.getClassProcessor().getMapRootClasses().get(leftType.value);
if (node != null && node.namelessConstructorStub) {
break; // skip last parameter of synthetic constructor call
}
if (i == parameters.size() - 1 && expr.getExprType() == VarType.VARTYPE_NULL && probablySyntheticParameter(leftType.value)) {
break; // skip last parameter of synthetic constructor call
}
if (!firstParam) {
@ -360,6 +357,11 @@ public class NewExprent extends Exprent {
return buf;
}
private static boolean probablySyntheticParameter(String className) {
ClassNode node = DecompilerContext.getClassProcessor().getMapRootClasses().get(className);
return node != null && node.type == ClassNode.CLASS_ANONYMOUS;
}
private static String getQualifiedNewInstance(String classname, List<Exprent> lstParams, int indent, BytecodeMappingTracer tracer) {
ClassNode node = DecompilerContext.getClassProcessor().getMapRootClasses().get(classname);

Loading…
Cancel
Save