diff --git a/plugins/java-decompiler/engine/src/org/jetbrains/java/decompiler/modules/decompiler/exps/Exprent.java b/plugins/java-decompiler/engine/src/org/jetbrains/java/decompiler/modules/decompiler/exps/Exprent.java index 2f9a93763d4b..13ac3dfbca6c 100644 --- a/plugins/java-decompiler/engine/src/org/jetbrains/java/decompiler/modules/decompiler/exps/Exprent.java +++ b/plugins/java-decompiler/engine/src/org/jetbrains/java/decompiler/modules/decompiler/exps/Exprent.java @@ -326,7 +326,7 @@ public abstract class Exprent implements IMatchable { } List lstAllExprents = getAllExprents(); - if (lstAllExprents == null || lstAllExprents.isEmpty()) { + if (lstAllExprents.isEmpty()) { return null; } diff --git a/plugins/java-decompiler/engine/test/org/jetbrains/java/decompiler/SingleClassesTest.java b/plugins/java-decompiler/engine/test/org/jetbrains/java/decompiler/SingleClassesTest.java index 0eef3ef2ed9b..3dbc589cb1b5 100644 --- a/plugins/java-decompiler/engine/test/org/jetbrains/java/decompiler/SingleClassesTest.java +++ b/plugins/java-decompiler/engine/test/org/jetbrains/java/decompiler/SingleClassesTest.java @@ -249,5 +249,7 @@ public class SingleClassesTest extends SingleClassesTestBase { @Test public void testLambda() { doTest("pkg/TestLambda"); } @Test public void testCustomSyntheticRecords() { doTest("pkg/TestCustomSyntheticRecords"); } @Test public void testFinally() { doTest("pkg/TestFinally"); } + @Test public void testEnumInit() { doTest("pkg/TestEnumInit"); } + @Test public void testGenericInit() { doTest("pkg/TestInitGeneric"); } } diff --git a/plugins/java-decompiler/engine/testData/classes/pkg/TestEnumInit$TestEnum.class b/plugins/java-decompiler/engine/testData/classes/pkg/TestEnumInit$TestEnum.class new file mode 100644 index 000000000000..fda66fb0d8bb Binary files /dev/null and b/plugins/java-decompiler/engine/testData/classes/pkg/TestEnumInit$TestEnum.class differ diff --git a/plugins/java-decompiler/engine/testData/classes/pkg/TestEnumInit$TestEnum1.class b/plugins/java-decompiler/engine/testData/classes/pkg/TestEnumInit$TestEnum1.class new file mode 100644 index 000000000000..c736ecca1eba Binary files /dev/null and b/plugins/java-decompiler/engine/testData/classes/pkg/TestEnumInit$TestEnum1.class differ diff --git a/plugins/java-decompiler/engine/testData/classes/pkg/TestEnumInit$TestEnum2.class b/plugins/java-decompiler/engine/testData/classes/pkg/TestEnumInit$TestEnum2.class new file mode 100644 index 000000000000..a2a41d427205 Binary files /dev/null and b/plugins/java-decompiler/engine/testData/classes/pkg/TestEnumInit$TestEnum2.class differ diff --git a/plugins/java-decompiler/engine/testData/classes/pkg/TestEnumInit.class b/plugins/java-decompiler/engine/testData/classes/pkg/TestEnumInit.class new file mode 100644 index 000000000000..e8a5d9509b1c Binary files /dev/null and b/plugins/java-decompiler/engine/testData/classes/pkg/TestEnumInit.class differ diff --git a/plugins/java-decompiler/engine/testData/classes/pkg/TestInitGeneric$A.class b/plugins/java-decompiler/engine/testData/classes/pkg/TestInitGeneric$A.class new file mode 100644 index 000000000000..0f8b43d9d110 Binary files /dev/null and b/plugins/java-decompiler/engine/testData/classes/pkg/TestInitGeneric$A.class differ diff --git a/plugins/java-decompiler/engine/testData/classes/pkg/TestInitGeneric$B.class b/plugins/java-decompiler/engine/testData/classes/pkg/TestInitGeneric$B.class new file mode 100644 index 000000000000..0a0a277f14e6 Binary files /dev/null and b/plugins/java-decompiler/engine/testData/classes/pkg/TestInitGeneric$B.class differ diff --git a/plugins/java-decompiler/engine/testData/classes/pkg/TestInitGeneric$C.class b/plugins/java-decompiler/engine/testData/classes/pkg/TestInitGeneric$C.class new file mode 100644 index 000000000000..71eac34cc75e Binary files /dev/null and b/plugins/java-decompiler/engine/testData/classes/pkg/TestInitGeneric$C.class differ diff --git a/plugins/java-decompiler/engine/testData/classes/pkg/TestInitGeneric.class b/plugins/java-decompiler/engine/testData/classes/pkg/TestInitGeneric.class new file mode 100644 index 000000000000..f7603f967675 Binary files /dev/null and b/plugins/java-decompiler/engine/testData/classes/pkg/TestInitGeneric.class differ diff --git a/plugins/java-decompiler/engine/testData/results/TestEnumInit.dec b/plugins/java-decompiler/engine/testData/results/TestEnumInit.dec new file mode 100644 index 000000000000..773a92c62804 --- /dev/null +++ b/plugins/java-decompiler/engine/testData/results/TestEnumInit.dec @@ -0,0 +1,74 @@ +package pkg; + +public class TestEnumInit { + public static void main(String[] args) { + }// 7 + + static enum TestEnum { + A, + B, + C; + } + + static enum TestEnum1 { + A(0), + B(1), + C(2); + + private final int anInt; + + private TestEnum1(int i) { + this.anInt = i;// 22 + }// 23 + } + + static enum TestEnum2 { + A(0, "0"), + B(1, "1"), + C(2, "2"); + + private final int anInt; + + private TestEnum2(int i, String s) { + this.anInt = i;// 35 + }// 36 + } +} + +class 'pkg/TestEnumInit' { + method 'main ([Ljava/lang/String;)V' { + 0 4 + } +} + +class 'pkg/TestEnumInit$TestEnum1' { + method ' (Ljava/lang/String;II)V' { + 6 20 + 7 20 + 8 20 + 9 20 + a 20 + b 21 + } +} + +class 'pkg/TestEnumInit$TestEnum2' { + method ' (Ljava/lang/String;IILjava/lang/String;)V' { + 6 32 + 7 32 + 8 32 + 9 32 + a 32 + b 33 + } +} + +Lines mapping: +7 <-> 5 +22 <-> 21 +23 <-> 22 +35 <-> 33 +36 <-> 34 +Not mapped: +21 +34 diff --git a/plugins/java-decompiler/engine/testData/results/TestInitGeneric.dec b/plugins/java-decompiler/engine/testData/results/TestInitGeneric.dec new file mode 100644 index 000000000000..e03ee4277b63 --- /dev/null +++ b/plugins/java-decompiler/engine/testData/results/TestInitGeneric.dec @@ -0,0 +1,111 @@ +package pkg; + +import java.util.List; + +public class TestInitGeneric { + public static void main(String[] args) { + }// 10 + + public T test() { + return (T)null;// 13 + } + + class A { + public T test() { + return (T)null;// 18 + } + } + + class B { + public L test() { + return (L)null;// 24 + } + + public AA test2() { + return (AA)null;// 28 + } + } + + static class C { + public K test(List list) { + return (K)null;// 34 + } + + public L test2(List list) { + L l = (L)(list.get(0));// 38 + System.out.println(l);// 39 + return l;// 40 + } + } +} + +class 'pkg/TestInitGeneric' { + method 'main ([Ljava/lang/String;)V' { + 0 6 + } + + method 'test ()Ljava/lang/Object;' { + 0 9 + 1 9 + } +} + +class 'pkg/TestInitGeneric$A' { + method 'test ()Ljava/lang/Object;' { + 0 14 + 1 14 + } +} + +class 'pkg/TestInitGeneric$B' { + method 'test ()Ljava/lang/Object;' { + 0 20 + 1 20 + } + + method 'test2 ()Ljava/lang/CharSequence;' { + 0 24 + 1 24 + } +} + +class 'pkg/TestInitGeneric$C' { + method 'test (Ljava/util/List;)Ljava/lang/Object;' { + 0 30 + 1 30 + } + + method 'test2 (Ljava/util/List;)Ljava/lang/CharSequence;' { + 0 34 + 1 34 + 2 34 + 3 34 + 4 34 + 5 34 + 6 34 + 7 34 + 8 34 + 9 34 + a 34 + b 35 + c 35 + d 35 + e 35 + f 35 + 10 35 + 11 35 + 12 36 + 13 36 + } +} + +Lines mapping: +10 <-> 7 +13 <-> 10 +18 <-> 15 +24 <-> 21 +28 <-> 25 +34 <-> 31 +38 <-> 35 +39 <-> 36 +40 <-> 37 diff --git a/plugins/java-decompiler/engine/testData/src/pkg/TestEnumInit.java b/plugins/java-decompiler/engine/testData/src/pkg/TestEnumInit.java new file mode 100644 index 000000000000..5a17a064ca34 --- /dev/null +++ b/plugins/java-decompiler/engine/testData/src/pkg/TestEnumInit.java @@ -0,0 +1,38 @@ +package pkg; + +public class TestEnumInit { + + public static void main(String[] args) { + + } + + enum TestEnum { + A, B, C; + } + + enum TestEnum1 { + + A(0), + B(1), + C(2); + + private final int anInt; + + TestEnum1(int i) { + anInt = i; + } + } + + enum TestEnum2 { + + A(0, "0"), + B(1, "1"), + C(2, "2"); + + private final int anInt; + + TestEnum2(int i, String s) { + anInt = i; + } + } +} \ No newline at end of file diff --git a/plugins/java-decompiler/engine/testData/src/pkg/TestInitGeneric.java b/plugins/java-decompiler/engine/testData/src/pkg/TestInitGeneric.java new file mode 100644 index 000000000000..6296224a9d5b --- /dev/null +++ b/plugins/java-decompiler/engine/testData/src/pkg/TestInitGeneric.java @@ -0,0 +1,45 @@ +package pkg; + +import java.util.List; + +public class TestInitGeneric { + + + public static void main(String[] args) { + + } + + public T test() { + return null; + } + + class A { + public T test() { + return null; + } + } + + class B { + public L test() { + return null; + } + + public AA test2() { + return null; + } + } + + static class C { + public K test(List list) { + return null; + } + + public L test2(List list) { + L l = list.get(0); + System.out.println(l); + return l; + } + + + } +} \ No newline at end of file