From: aclement Date: Thu, 27 Nov 2008 21:30:47 +0000 (+0000) Subject: 256669: itd parameter annotations copied to target X-Git-Tag: V1_6_3rc1~91 X-Git-Url: https://source.dussan.org/?a=commitdiff_plain;h=48ba3fea26bf31e702199528bd461eaff4cc535c;p=aspectj.git 256669: itd parameter annotations copied to target --- diff --git a/tests/bugs163/pr256669/Destination.java b/tests/bugs163/pr256669/Destination.java new file mode 100644 index 000000000..30852cabb --- /dev/null +++ b/tests/bugs163/pr256669/Destination.java @@ -0,0 +1 @@ +public class Destination {} diff --git a/tests/bugs163/pr256669/Four.java b/tests/bugs163/pr256669/Four.java new file mode 100644 index 000000000..5d2a6747a --- /dev/null +++ b/tests/bugs163/pr256669/Four.java @@ -0,0 +1,40 @@ +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 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 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 ""; +} diff --git a/tests/bugs163/pr256669/Introduction.java b/tests/bugs163/pr256669/Introduction.java new file mode 100644 index 000000000..8539a8551 --- /dev/null +++ b/tests/bugs163/pr256669/Introduction.java @@ -0,0 +1,6 @@ +privileged aspect Introduction { + public String Destination.helloWorld(@SomeAnnotation("xyz") String who) { + return "Hello " + who; + } +} + diff --git a/tests/bugs163/pr256669/SimpleTest.java b/tests/bugs163/pr256669/SimpleTest.java new file mode 100644 index 000000000..22303af65 --- /dev/null +++ b/tests/bugs163/pr256669/SimpleTest.java @@ -0,0 +1,22 @@ +import java.lang.reflect.*; +import java.lang.annotation.*; + +public class SimpleTest { + public static void main(String[] argv) throws Exception { + Class 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"); + } + + } +} + diff --git a/tests/bugs163/pr256669/SomeAnnotation.java b/tests/bugs163/pr256669/SomeAnnotation.java new file mode 100644 index 000000000..e12cde1c7 --- /dev/null +++ b/tests/bugs163/pr256669/SomeAnnotation.java @@ -0,0 +1,7 @@ +import java.lang.annotation.*; + +@Retention(RetentionPolicy.RUNTIME) +@Target(ElementType.PARAMETER) +public @interface SomeAnnotation { + String value() default ""; +} diff --git a/tests/bugs163/pr256669/Three.java b/tests/bugs163/pr256669/Three.java new file mode 100644 index 000000000..dc487832d --- /dev/null +++ b/tests/bugs163/pr256669/Three.java @@ -0,0 +1,31 @@ +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 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 ""; +} diff --git a/tests/bugs163/pr256669/Two.java b/tests/bugs163/pr256669/Two.java new file mode 100644 index 000000000..795825e51 --- /dev/null +++ b/tests/bugs163/pr256669/Two.java @@ -0,0 +1,31 @@ +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 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 ""; +} diff --git a/tests/src/org/aspectj/systemtest/ajc163/Ajc163Tests.java b/tests/src/org/aspectj/systemtest/ajc163/Ajc163Tests.java index 7a38f7265..6107200df 100644 --- a/tests/src/org/aspectj/systemtest/ajc163/Ajc163Tests.java +++ b/tests/src/org/aspectj/systemtest/ajc163/Ajc163Tests.java @@ -23,6 +23,22 @@ import org.aspectj.testing.XMLBasedAjcTestCase; 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"); } @@ -31,9 +47,9 @@ public class Ajc163Tests extends org.aspectj.testing.XMLBasedAjcTestCase { 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"); @@ -51,7 +67,6 @@ public class Ajc163Tests extends org.aspectj.testing.XMLBasedAjcTestCase { runTest("generic pointcuts - 4"); } - // public void testBrokenLVT_pr194314_1() throws Exception { // runTest("broken lvt - 1"); // JavaClass jc = Utils.getClassFrom(ajc.getSandboxDirectory().getAbsolutePath(), "Service"); diff --git a/tests/src/org/aspectj/systemtest/ajc163/ajc163.xml b/tests/src/org/aspectj/systemtest/ajc163/ajc163.xml index f3e82e8ed..ac29d0aa3 100644 --- a/tests/src/org/aspectj/systemtest/ajc163/ajc163.xml +++ b/tests/src/org/aspectj/systemtest/ajc163/ajc163.xml @@ -16,6 +16,46 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +