--- /dev/null
+public class Destination {}
--- /dev/null
+import java.lang.reflect.*;
+import java.lang.annotation.*;
+
+
+interface I {}
+
+class D implements I {}
+
+aspect Introduction {
+ // ITD onto interface
+ public String I.helloWorld( @SomeAnnotation("xyz") String who) {
+ return "Hello " + who;
+ }
+}
+
+public class Four {
+ public static void main(String[] argv) throws Exception {
+ Class<D> clazz = D.class;
+ Method m = clazz.getMethod("helloWorld", String.class);
+ Annotation[] ann = m.getAnnotations();
+ for (int i = 0; i < m.getParameterAnnotations().length; i++) {
+ int count = m.getParameterAnnotations()[i].length;
+ System.out.println("Class D parameter " + i + " has " + count + " parameter annotations");
+ }
+ Class<I> clazzI = I.class;
+ m = clazzI.getMethod("helloWorld", String.class);
+ ann = m.getAnnotations();
+ for (int i = 0; i < m.getParameterAnnotations().length; i++) {
+ int count = m.getParameterAnnotations()[i].length;
+ System.out.println("Interface I parameter " + i + " has " + count + " parameter annotations");
+ }
+
+ }
+}
+
+@Retention(RetentionPolicy.RUNTIME)
+@Target(ElementType.PARAMETER)
+@interface SomeAnnotation {
+ String value() default "";
+}
--- /dev/null
+privileged aspect Introduction {
+ public String Destination.helloWorld(@SomeAnnotation("xyz") String who) {
+ return "Hello " + who;
+ }
+}
+
--- /dev/null
+import java.lang.reflect.*;
+import java.lang.annotation.*;
+
+public class SimpleTest {
+ public static void main(String[] argv) throws Exception {
+ Class<Destination> clazz = Destination.class;
+ Method m = clazz.getMethod("helloWorld", String.class);
+ Annotation[] ann = m.getAnnotations();
+// System.out.println(m + " has " + ann.length + " annotations");
+
+ for (int i = 0; i < ann.length; i++) {
+// System.out.println("Method annotation: " + ann[i].getClass() + ann[i].toString());
+ }
+
+ for (int i = 0; i < m.getParameterAnnotations().length; i++) {
+ int count = m.getParameterAnnotations()[i].length;
+ System.out.println("Parameter " + i + " has " + count + " parameter annotations");
+ }
+
+ }
+}
+
--- /dev/null
+import java.lang.annotation.*;
+
+@Retention(RetentionPolicy.RUNTIME)
+@Target(ElementType.PARAMETER)
+public @interface SomeAnnotation {
+ String value() default "";
+}
--- /dev/null
+import java.lang.reflect.*;
+import java.lang.annotation.*;
+
+
+class Destination {}
+
+aspect Introduction {
+ // multiple parameters, not all annotated
+ public static String Destination.helloWorld(int i, @SomeAnnotation("xyz") String who, long l, @SomeAnnotation("abc") String what) {
+ return "Hello " + who;
+ }
+}
+
+public class Three {
+ public static void main(String[] argv) throws Exception {
+ Class<Destination> clazz = Destination.class;
+ Method m = clazz.getMethod("helloWorld", Integer.TYPE,String.class,Long.TYPE,String.class);
+ Annotation[] ann = m.getAnnotations();
+ for (int i = 0; i < m.getParameterAnnotations().length; i++) {
+ int count = m.getParameterAnnotations()[i].length;
+ System.out.println("Parameter " + i + " has " + count + " parameter annotations");
+ }
+
+ }
+}
+
+@Retention(RetentionPolicy.RUNTIME)
+@Target(ElementType.PARAMETER)
+@interface SomeAnnotation {
+ String value() default "";
+}
--- /dev/null
+import java.lang.reflect.*;
+import java.lang.annotation.*;
+
+
+class Destination {}
+
+aspect Introduction {
+ // static ITD
+ public static String Destination.helloWorld(@SomeAnnotation("xyz") String who) {
+ return "Hello " + who;
+ }
+}
+
+public class Two {
+ public static void main(String[] argv) throws Exception {
+ Class<Destination> clazz = Destination.class;
+ Method m = clazz.getMethod("helloWorld", String.class);
+ Annotation[] ann = m.getAnnotations();
+ for (int i = 0; i < m.getParameterAnnotations().length; i++) {
+ int count = m.getParameterAnnotations()[i].length;
+ System.out.println("Parameter " + i + " has " + count + " parameter annotations");
+ }
+
+ }
+}
+
+@Retention(RetentionPolicy.RUNTIME)
+@Target(ElementType.PARAMETER)
+@interface SomeAnnotation {
+ String value() default "";
+}
public class Ajc163Tests extends org.aspectj.testing.XMLBasedAjcTestCase {
+ public void testParameterAnnotationsOnITDs_pr256669() { // regular itd
+ runTest("parameter annotations on ITDs");
+ }
+
+ public void testParameterAnnotationsOnITDs_pr256669_2() { // static itd
+ runTest("parameter annotations on ITDs - 2");
+ }
+
+ public void testParameterAnnotationsOnITDs_pr256669_3() { // multiple parameters
+ runTest("parameter annotations on ITDs - 3");
+ }
+
+ public void testParameterAnnotationsOnITDs_pr256669_4() { // itd on interface
+ runTest("parameter annotations on ITDs - 4");
+ }
+
public void testOrderingIssue_1() {
runTest("ordering issue");
}
runTest("ordering issue - 2");
}
-// public void testGenericPointcuts_5() {
-// runTest("generic pointcuts - 5");
-// }
+ // public void testGenericPointcuts_5() {
+ // runTest("generic pointcuts - 5");
+ // }
public void testGenericPointcuts_1() {
runTest("generic pointcuts - 1");
runTest("generic pointcuts - 4");
}
-
// public void testBrokenLVT_pr194314_1() throws Exception {
// runTest("broken lvt - 1");
// JavaClass jc = Utils.getClassFrom(ajc.getSandboxDirectory().getAbsolutePath(), "Service");
<message kind="error" line="1" text="Bound mismatch"/>
</compile>
</ajc-test>
+
+ <ajc-test dir="bugs163/pr256669" title="parameter annotations on ITDs">
+ <compile files="Destination.java SimpleTest.java Introduction.java SomeAnnotation.java" options="-1.5"/>
+ <run class="SimpleTest">
+ <stdout>
+ <line text="Parameter 0 has 1 parameter annotations"/>
+ </stdout>
+ </run>
+ </ajc-test>
+
+ <ajc-test dir="bugs163/pr256669" title="parameter annotations on ITDs - 2">
+ <compile files="Two.java" options="-1.5"/>
+ <run class="Two">
+ <stdout>
+ <line text="Parameter 0 has 1 parameter annotations"/>
+ </stdout>
+ </run>
+ </ajc-test>
+
+ <ajc-test dir="bugs163/pr256669" title="parameter annotations on ITDs - 3">
+ <compile files="Three.java" options="-1.5"/>
+ <run class="Three">
+ <stdout>
+ <line text="Parameter 0 has 0 parameter annotations"/>
+ <line text="Parameter 1 has 1 parameter annotations"/>
+ <line text="Parameter 2 has 0 parameter annotations"/>
+ <line text="Parameter 3 has 1 parameter annotations"/>
+ </stdout>
+ </run>
+ </ajc-test>
+
+ <ajc-test dir="bugs163/pr256669" title="parameter annotations on ITDs - 4">
+ <compile files="Four.java" options="-1.5"/>
+ <run class="Four">
+ <stdout>
+ <line text="Class D parameter 0 has 1 parameter annotations"/>
+ <line text="Interface I parameter 0 has 1 parameter annotations"/>
+ </stdout>
+ </run>
+ </ajc-test>
<ajc-test dir="bugs163/pr253109" title="generic pointcuts - 1">
<compile files="CodeOne.java" options="-1.5">