From: Alexander Kriegisch Date: Sat, 24 Jun 2023 06:15:24 +0000 (+0200) Subject: Add failing test reproducing #246 X-Git-Tag: V1_9_20~13 X-Git-Url: https://source.dussan.org/?a=commitdiff_plain;h=1e2d9683b4b0d75dfd9830ebeb482e56cf40fd8d;p=aspectj.git Add failing test reproducing #246 Signed-off-by: Alexander Kriegisch --- diff --git a/tests/bugs1920/github_246/App.java b/tests/bugs1920/github_246/App.java new file mode 100644 index 000000000..8e0bbe8bf --- /dev/null +++ b/tests/bugs1920/github_246/App.java @@ -0,0 +1,11 @@ +import java.lang.reflect.Method; +import java.util.Arrays; + +public class App { + public static void main(String[] args) { + for (Method method : App.class.getDeclaredMethods()) { + if (method.getName().equals("foo")) + System.out.println(Arrays.toString(method.getDeclaredAnnotations()) + " " + method); + } + } +} diff --git a/tests/bugs1920/github_246/First.java b/tests/bugs1920/github_246/First.java new file mode 100644 index 000000000..aa482ca6d --- /dev/null +++ b/tests/bugs1920/github_246/First.java @@ -0,0 +1,5 @@ +import java.lang.annotation.Retention; +import java.lang.annotation.RetentionPolicy; + +@Retention(RetentionPolicy.RUNTIME) +public @interface First { } diff --git a/tests/bugs1920/github_246/ITDAspect.aj b/tests/bugs1920/github_246/ITDAspect.aj new file mode 100644 index 000000000..fffef1651 --- /dev/null +++ b/tests/bugs1920/github_246/ITDAspect.aj @@ -0,0 +1,13 @@ +public aspect ITDAspect { + @First + @Second + public void App.foo(Object parameter) { } + + @First + public void App.foo(String parameter) { } + + @Second + public int App.foo(int parameter) { + return parameter + 3; + } +} diff --git a/tests/bugs1920/github_246/Second.java b/tests/bugs1920/github_246/Second.java new file mode 100644 index 000000000..d599f7b1a --- /dev/null +++ b/tests/bugs1920/github_246/Second.java @@ -0,0 +1,5 @@ +import java.lang.annotation.Retention; +import java.lang.annotation.RetentionPolicy; + +@Retention(RetentionPolicy.RUNTIME) +public @interface Second { } diff --git a/tests/src/test/java/org/aspectj/systemtest/ajc1920/Bugs1920Tests.java b/tests/src/test/java/org/aspectj/systemtest/ajc1920/Bugs1920Tests.java index fca9fee20..409a2e675 100644 --- a/tests/src/test/java/org/aspectj/systemtest/ajc1920/Bugs1920Tests.java +++ b/tests/src/test/java/org/aspectj/systemtest/ajc1920/Bugs1920Tests.java @@ -15,8 +15,15 @@ import org.aspectj.testing.XMLBasedAjcTestCase; */ public class Bugs1920Tests extends XMLBasedAjcTestCase { - public void testDummyJava20() { - //runTest("dummy Java 20"); + /** + * Add correct annotations to multiple ITD methods with the same name and same number of arguments, i.e. copy the + * annotations correctly from the aspect into the target class instead of falsely always copying the annotations (if + * any) from the first ITD method found. + *

+ * See GitHub issue 246. + */ + public void test_GitHub_246() { + runTest("add correct annotations to multiple ITD methods with the same name and same number of arguments"); } public static Test suite() { diff --git a/tests/src/test/resources/org/aspectj/systemtest/ajc1920/ajc1920.xml b/tests/src/test/resources/org/aspectj/systemtest/ajc1920/ajc1920.xml index 8f566b643..2026df491 100644 --- a/tests/src/test/resources/org/aspectj/systemtest/ajc1920/ajc1920.xml +++ b/tests/src/test/resources/org/aspectj/systemtest/ajc1920/ajc1920.xml @@ -176,4 +176,16 @@ + + + + + + + + + + + +