diff --git a/java/java-tests/testData/psi/cls/mirror/MemberAnnotations.txt b/java/java-tests/testData/psi/cls/mirror/MemberAnnotations.txt new file mode 100644 index 000000000000..f7f1b70e4252 --- /dev/null +++ b/java/java-tests/testData/psi/cls/mirror/MemberAnnotations.txt @@ -0,0 +1,22 @@ + + // IntelliJ API Decompiler stub source generated from a class file + // Implementation of methods is not available + +package pkg; + +class MemberAnnotations { + @pkg.MemberAnnotations.A("const") + public static final int CONST = 42; + @pkg.MemberAnnotations.A("field") + private int f; + + MemberAnnotations() { /* compiled code */ } + + @pkg.MemberAnnotations.A("return") + private int f(@pkg.MemberAnnotations.A("arg") int i) { /* compiled code */ } + + @java.lang.annotation.Retention(java.lang.annotation.RetentionPolicy.RUNTIME) + static @interface A { + java.lang.String value() default ""; + } +} \ No newline at end of file diff --git a/java/java-tests/testData/psi/cls/mirror/pkg/MemberAnnotations$A.class b/java/java-tests/testData/psi/cls/mirror/pkg/MemberAnnotations$A.class new file mode 100644 index 000000000000..e2bd13c1cc4b Binary files /dev/null and b/java/java-tests/testData/psi/cls/mirror/pkg/MemberAnnotations$A.class differ diff --git a/java/java-tests/testData/psi/cls/mirror/pkg/MemberAnnotations.class b/java/java-tests/testData/psi/cls/mirror/pkg/MemberAnnotations.class new file mode 100644 index 000000000000..375246510a38 Binary files /dev/null and b/java/java-tests/testData/psi/cls/mirror/pkg/MemberAnnotations.class differ diff --git a/java/java-tests/testData/psi/cls/mirror/src/pkg/MemberAnnotations.java b/java/java-tests/testData/psi/cls/mirror/src/pkg/MemberAnnotations.java new file mode 100644 index 000000000000..e980db8209d2 --- /dev/null +++ b/java/java-tests/testData/psi/cls/mirror/src/pkg/MemberAnnotations.java @@ -0,0 +1,13 @@ +package pkg; + +import java.lang.annotation.*; + +class MemberAnnotations { + @Retention(RetentionPolicy.RUNTIME) + @interface A { String value() default ""; } + + @A("const") public static final int CONST = 42; + @A("field") private int f; + + @A("return") private int f(@A("arg") int i) { return i + f + CONST; } +} \ No newline at end of file diff --git a/java/java-tests/testSrc/com/intellij/psi/ClsMirrorBuildingTest.java b/java/java-tests/testSrc/com/intellij/psi/ClsMirrorBuildingTest.java index 9069a30bf2c6..479bbb67b358 100644 --- a/java/java-tests/testSrc/com/intellij/psi/ClsMirrorBuildingTest.java +++ b/java/java-tests/testSrc/com/intellij/psi/ClsMirrorBuildingTest.java @@ -45,6 +45,7 @@ public class ClsMirrorBuildingTest extends LightIdeaTestCase { public void testDeprecated() { doTest(); } public void testAnnotations() { doTest(); } public void testMoreAnnotations() { doTest(); } + public void testMemberAnnotations() { doTest(); } public void testParameterNames() { doTest(); } public void testEmptyEnum() { doTest(); } public void test$BuckClass() { doTest(); } 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 e3a6f56a7979..5647ab82ee6a 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 @@ -81,6 +81,7 @@ public class SingleClassesTest { @Test public void testJava9StringConcat() { doTest("java9/TestJava9StringConcat"); } @Test public void testMethodReferenceSameName() { doTest("pkg/TestMethodReferenceSameName"); } @Test public void testMethodReferenceLetterClass() { doTest("pkg/TestMethodReferenceLetterClass"); } + @Test public void testMemberAnnotations() { doTest("pkg/TestMemberAnnotations"); } protected void doTest(String testFile, String... companionFiles) { ConsoleDecompiler decompiler = fixture.getDecompiler(); diff --git a/plugins/java-decompiler/engine/testData/classes/pkg/TestMemberAnnotations$A.class b/plugins/java-decompiler/engine/testData/classes/pkg/TestMemberAnnotations$A.class new file mode 100644 index 000000000000..f7fa7905d1df Binary files /dev/null and b/plugins/java-decompiler/engine/testData/classes/pkg/TestMemberAnnotations$A.class differ diff --git a/plugins/java-decompiler/engine/testData/classes/pkg/TestMemberAnnotations.class b/plugins/java-decompiler/engine/testData/classes/pkg/TestMemberAnnotations.class new file mode 100644 index 000000000000..cb09ec42b752 Binary files /dev/null and b/plugins/java-decompiler/engine/testData/classes/pkg/TestMemberAnnotations.class differ diff --git a/plugins/java-decompiler/engine/testData/results/TestMemberAnnotations.dec b/plugins/java-decompiler/engine/testData/results/TestMemberAnnotations.dec new file mode 100644 index 000000000000..1e3a41c0f8ac --- /dev/null +++ b/plugins/java-decompiler/engine/testData/results/TestMemberAnnotations.dec @@ -0,0 +1,34 @@ +package pkg; + +import java.lang.annotation.Retention; +import java.lang.annotation.RetentionPolicy; + +class TestMemberAnnotations { + @TestMemberAnnotations.A("const") + public static final int CONST = 42; + @TestMemberAnnotations.A("field") + private int f; + + @TestMemberAnnotations.A("return") + private int f(@TestMemberAnnotations.A("arg") int var1) { + return var1 + this.f + 42;// 12 + } + + @Retention(RetentionPolicy.RUNTIME) + @interface A { + String value() default ""; + } +} + +class 'pkg/TestMemberAnnotations' { + method 'f (I)I' { + 2 13 + 5 13 + 6 13 + 8 13 + 9 13 + } +} + +Lines mapping: +12 <-> 14 diff --git a/plugins/java-decompiler/engine/testData/src/pkg/TestMemberAnnotations.java b/plugins/java-decompiler/engine/testData/src/pkg/TestMemberAnnotations.java new file mode 100644 index 000000000000..b7c7da9bf7a2 --- /dev/null +++ b/plugins/java-decompiler/engine/testData/src/pkg/TestMemberAnnotations.java @@ -0,0 +1,13 @@ +package pkg; + +import java.lang.annotation.*; + +class TestMemberAnnotations { + @Retention(RetentionPolicy.RUNTIME) + @interface A { String value() default ""; } + + @A("const") public static final int CONST = 42; + @A("field") private int f; + + @A("return") private int f(@A("arg") int i) { return i + f + CONST; } +} \ No newline at end of file