--- /dev/null
+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);
+ }
+ }
+}
--- /dev/null
+import java.lang.annotation.Retention;
+import java.lang.annotation.RetentionPolicy;
+
+@Retention(RetentionPolicy.RUNTIME)
+public @interface First { }
--- /dev/null
+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;
+ }
+}
--- /dev/null
+import java.lang.annotation.Retention;
+import java.lang.annotation.RetentionPolicy;
+
+@Retention(RetentionPolicy.RUNTIME)
+public @interface Second { }
*/
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.
+ * <p>
+ * See <a href="https://github.com/eclipse-aspectj/aspectj/issues/246">GitHub issue 246</a>.
+ */
+ 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() {
</run>
</ajc-test>
+ <!-- https://github.com/eclipse-aspectj/aspectj/issues/246 -->
+ <ajc-test dir="bugs1920/github_246" vm="8" title="add correct annotations to multiple ITD methods with the same name and same number of arguments">
+ <compile files="First.java Second.java App.java ITDAspect.aj" options="-8"/>
+ <run class="App">
+ <stdout>
+ <line text="[@First(), @Second()] public void App.foo(java.lang.Object)"/>
+ <line text="[@First()] public void App.foo(java.lang.String)"/>
+ <line text="[@Second()] public int App.foo(int)"/>
+ </stdout>
+ </run>
+ </ajc-test>
+
</suite>