diff options
author | aclement <aclement> | 2008-11-27 21:30:47 +0000 |
---|---|---|
committer | aclement <aclement> | 2008-11-27 21:30:47 +0000 |
commit | 48ba3fea26bf31e702199528bd461eaff4cc535c (patch) | |
tree | 31719f1e83effb1d6c808e45ce03266d2b7b10b5 /tests/bugs163 | |
parent | 155a888d39e73a70fd4fe47de2c37ed593bb5459 (diff) | |
download | aspectj-48ba3fea26bf31e702199528bd461eaff4cc535c.tar.gz aspectj-48ba3fea26bf31e702199528bd461eaff4cc535c.zip |
256669: itd parameter annotations copied to target
Diffstat (limited to 'tests/bugs163')
-rw-r--r-- | tests/bugs163/pr256669/Destination.java | 1 | ||||
-rw-r--r-- | tests/bugs163/pr256669/Four.java | 40 | ||||
-rw-r--r-- | tests/bugs163/pr256669/Introduction.java | 6 | ||||
-rw-r--r-- | tests/bugs163/pr256669/SimpleTest.java | 22 | ||||
-rw-r--r-- | tests/bugs163/pr256669/SomeAnnotation.java | 7 | ||||
-rw-r--r-- | tests/bugs163/pr256669/Three.java | 31 | ||||
-rw-r--r-- | tests/bugs163/pr256669/Two.java | 31 |
7 files changed, 138 insertions, 0 deletions
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<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 ""; +} 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<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"); + } + + } +} + 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<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 ""; +} 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<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 ""; +} |