Skip to content

Commit

Permalink
Fix J21 nested inner class synthetic params
Browse files Browse the repository at this point in the history
  • Loading branch information
jaskarth committed Apr 16, 2024
1 parent 1b76be3 commit ddf8471
Show file tree
Hide file tree
Showing 4 changed files with 60 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -807,7 +807,7 @@ private static String getEnclosingVarField(StructClass cl, MethodWrapper method,
StructMethodParametersAttribute attr = method.methodStruct.getAttribute(StructGeneralAttribute.ATTRIBUTE_METHOD_PARAMETERS);

List<StructMethodParametersAttribute.Entry> entries = attr.getEntries();
if (outerIdx < entries.size() && (entries.get(outerIdx).myAccessFlags & CodeConstants.ACC_MANDATED) == CodeConstants.ACC_MANDATED) {
if (outerIdx < entries.size() && (entries.get(outerIdx).myAccessFlags & (CodeConstants.ACC_MANDATED | CodeConstants.ACC_SYNTHETIC)) != 0) {

String name = method.varproc.getVarName(var);
VarType type = method.varproc.getVarType(var);
Expand Down
1 change: 1 addition & 0 deletions test/org/jetbrains/java/decompiler/SingleClassesTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -697,6 +697,7 @@ private void registerDefault() {
register(JAVA_8, "TestDanglingBoxingCall");
register(JAVA_21, "TestSwitchOnEnumJ21", "ext/TestEnum2");
register(JAVA_21, "TestInnerClassesJ21");
register(JAVA_21, "TestInnerClasses2J21");
register(JAVA_8, "TestInnerClassesJ8");
register(JAVA_8, "TestSwitchInTry");
}
Expand Down
43 changes: 43 additions & 0 deletions testData/results/pkg/TestInnerClasses2J21.dec
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
package pkg;

public class TestInnerClasses2J21 {
private void test() {
new TestInnerClasses2J21.Inner().new Inner2(true, true);// 5
}// 6

private class Inner {
private class Inner2 {
private Inner2(boolean nonFinal, final boolean finalB) {
TestInnerClasses2J21.this.test();// 11
}// 12
}
}
}

class 'pkg/TestInnerClasses2J21' {
method 'test ()V' {
c 4
d 4
12 5
}
}

class 'pkg/TestInnerClasses2J21$Inner$Inner2' {
method '<init> (Lpkg/TestInnerClasses2J21$Inner;ZZ)V' {
5 10
6 10
7 10
8 10
9 10
a 10
b 11
}
}

Lines mapping:
5 <-> 5
6 <-> 6
11 <-> 11
12 <-> 12
Not mapped:
10
15 changes: 15 additions & 0 deletions testData/src/java21/pkg/TestInnerClasses2J21.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
package pkg;

public class TestInnerClasses2J21 {
private void test() {
new Inner().new Inner2(true, true);
}

private class Inner {
private class Inner2 {
private Inner2(boolean nonFinal, final boolean finalB) {
TestInnerClasses2J21.this.test();
}
}
}
}

0 comments on commit ddf8471

Please sign in to comment.