mirror of
https://github.com/moparisthebest/fernflower
synced 2024-11-22 09:12:17 -05:00
EA-41231 (omit synthetic inner class constructor parameter)
This commit is contained in:
parent
373ca99e37
commit
6889e7435a
@ -250,7 +250,7 @@ public class ClassWriter {
|
|||||||
for (ClassNode inner : node.nested) {
|
for (ClassNode inner : node.nested) {
|
||||||
if (inner.type == ClassNode.CLASS_MEMBER) {
|
if (inner.type == ClassNode.CLASS_MEMBER) {
|
||||||
StructClass innerCl = inner.classStruct;
|
StructClass innerCl = inner.classStruct;
|
||||||
boolean isSynthetic = (inner.access & CodeConstants.ACC_SYNTHETIC) != 0 || innerCl.isSynthetic();
|
boolean isSynthetic = (inner.access & CodeConstants.ACC_SYNTHETIC) != 0 || innerCl.isSynthetic() || inner.namelessConstructorStub;
|
||||||
boolean hide = isSynthetic && DecompilerContext.getOption(IFernflowerPreferences.REMOVE_SYNTHETIC) ||
|
boolean hide = isSynthetic && DecompilerContext.getOption(IFernflowerPreferences.REMOVE_SYNTHETIC) ||
|
||||||
wrapper.getHiddenMembers().contains(innerCl.qualifiedName);
|
wrapper.getHiddenMembers().contains(innerCl.qualifiedName);
|
||||||
if (hide) continue;
|
if (hide) continue;
|
||||||
|
@ -359,6 +359,7 @@ public class ClassesProcessor {
|
|||||||
public Set<String> enclosingClasses = new HashSet<String>();
|
public Set<String> enclosingClasses = new HashSet<String>();
|
||||||
public ClassNode parent;
|
public ClassNode parent;
|
||||||
public LambdaInformation lambdaInformation;
|
public LambdaInformation lambdaInformation;
|
||||||
|
public boolean namelessConstructorStub = false;
|
||||||
|
|
||||||
public ClassNode(String content_class_name,
|
public ClassNode(String content_class_name,
|
||||||
String content_method_name,
|
String content_method_name,
|
||||||
|
@ -79,6 +79,7 @@ public class NestedClassProcessor {
|
|||||||
DecompilerContext.getLogger().writeMessage(message, IFernflowerLogger.Severity.WARN);
|
DecompilerContext.getLogger().writeMessage(message, IFernflowerLogger.Severity.WARN);
|
||||||
child.simpleName = "NamelessClass_" + (++nameless);
|
child.simpleName = "NamelessClass_" + (++nameless);
|
||||||
}
|
}
|
||||||
|
child.namelessConstructorStub = !cl.hasModifier(CodeConstants.ACC_STATIC) && cl.getMethods().size() + cl.getFields().size() == 0;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -311,20 +311,31 @@ public class NewExprent extends Exprent {
|
|||||||
if (!enumconst || start < lstParameters.size()) {
|
if (!enumconst || start < lstParameters.size()) {
|
||||||
buf.append("(");
|
buf.append("(");
|
||||||
|
|
||||||
boolean firstpar = true;
|
boolean firstParam = true;
|
||||||
for (int i = start; i < lstParameters.size(); i++) {
|
for (int i = start; i < lstParameters.size(); i++) {
|
||||||
if (sigFields == null || sigFields.get(i) == null) {
|
if (sigFields == null || sigFields.get(i) == null) {
|
||||||
if (!firstpar) {
|
Exprent expr = lstParameters.get(i);
|
||||||
|
VarType leftType = constructor.getDescriptor().params[i];
|
||||||
|
|
||||||
|
if (i == lstParameters.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 (!firstParam) {
|
||||||
buf.append(", ");
|
buf.append(", ");
|
||||||
}
|
}
|
||||||
|
|
||||||
TextBuffer buff = new TextBuffer();
|
TextBuffer buff = new TextBuffer();
|
||||||
ExprProcessor.getCastedExprent(lstParameters.get(i), constructor.getDescriptor().params[i], buff, indent, true, tracer);
|
ExprProcessor.getCastedExprent(expr, leftType, buff, indent, true, tracer);
|
||||||
|
|
||||||
buf.append(buff);
|
buf.append(buff);
|
||||||
firstpar = false;
|
|
||||||
|
firstParam = false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
buf.append(")");
|
buf.append(")");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -34,4 +34,6 @@ public class SingleClassesTest extends SingleClassesTestBase {
|
|||||||
@Test public void testEnum() { doTest("pkg/TestEnum"); }
|
@Test public void testEnum() { doTest("pkg/TestEnum"); }
|
||||||
@Test public void testDebugSymbols() { doTest("pkg/TestDebugSymbols"); }
|
@Test public void testDebugSymbols() { doTest("pkg/TestDebugSymbols"); }
|
||||||
@Test public void testInvalidMethodSignature() { doTest("InvalidMethodSignature"); }
|
@Test public void testInvalidMethodSignature() { doTest("InvalidMethodSignature"); }
|
||||||
|
@Test public void testInnerClassConstructor() { doTest("pkg/TestInnerClassConstructor"); }
|
||||||
|
@Test public void testInnerClassConstructor11() { doTest("v11/TestInnerClassConstructor"); }
|
||||||
}
|
}
|
||||||
|
BIN
testData/classes/pkg/TestInnerClassConstructor$1.class
Normal file
BIN
testData/classes/pkg/TestInnerClassConstructor$1.class
Normal file
Binary file not shown.
BIN
testData/classes/pkg/TestInnerClassConstructor$Inner.class
Normal file
BIN
testData/classes/pkg/TestInnerClassConstructor$Inner.class
Normal file
Binary file not shown.
BIN
testData/classes/pkg/TestInnerClassConstructor.class
Normal file
BIN
testData/classes/pkg/TestInnerClassConstructor.class
Normal file
Binary file not shown.
BIN
testData/classes/v11/TestInnerClassConstructor$1.class
Normal file
BIN
testData/classes/v11/TestInnerClassConstructor$1.class
Normal file
Binary file not shown.
BIN
testData/classes/v11/TestInnerClassConstructor$Inner.class
Normal file
BIN
testData/classes/v11/TestInnerClassConstructor$Inner.class
Normal file
Binary file not shown.
BIN
testData/classes/v11/TestInnerClassConstructor.class
Normal file
BIN
testData/classes/v11/TestInnerClassConstructor.class
Normal file
Binary file not shown.
17
testData/results/TestInnerClassConstructor.dec
Normal file
17
testData/results/TestInnerClassConstructor.dec
Normal file
@ -0,0 +1,17 @@
|
|||||||
|
package pkg;
|
||||||
|
|
||||||
|
class TestInnerClassConstructor {
|
||||||
|
void m() {
|
||||||
|
new TestInnerClassConstructor.Inner("text");
|
||||||
|
}
|
||||||
|
|
||||||
|
void n(String var1) {
|
||||||
|
System.out.println("n(): " + var1);
|
||||||
|
}
|
||||||
|
|
||||||
|
final class Inner {
|
||||||
|
private Inner(String var2) {
|
||||||
|
TestInnerClassConstructor.this.n(var2);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
17
testData/src/pkg/TestInnerClassConstructor.java
Normal file
17
testData/src/pkg/TestInnerClassConstructor.java
Normal file
@ -0,0 +1,17 @@
|
|||||||
|
package pkg;
|
||||||
|
|
||||||
|
class TestInnerClassConstructor {
|
||||||
|
void m() {
|
||||||
|
new Inner("text");
|
||||||
|
}
|
||||||
|
|
||||||
|
void n(String s) {
|
||||||
|
System.out.println("n(): " + s);
|
||||||
|
}
|
||||||
|
|
||||||
|
final class Inner {
|
||||||
|
private Inner(String s) {
|
||||||
|
n(s);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
Loading…
Reference in New Issue
Block a user