aboutsummaryrefslogtreecommitdiffstats
path: root/tests/bugs151/pr133298
diff options
context:
space:
mode:
authoraclement <aclement>2006-03-26 18:15:39 +0000
committeraclement <aclement>2006-03-26 18:15:39 +0000
commitf963fc4dcd3f0391e6eb234c3346d16eb5bdb891 (patch)
tree168bdd307060e43cc4bd6b60d2ea095d075c99a5 /tests/bugs151/pr133298
parent2fb86fe604b613774492df5185b1c5717c434d29 (diff)
downloadaspectj-f963fc4dcd3f0391e6eb234c3346d16eb5bdb891.tar.gz
aspectj-f963fc4dcd3f0391e6eb234c3346d16eb5bdb891.zip
better tests for 133298 - yucky bug.
Diffstat (limited to 'tests/bugs151/pr133298')
-rw-r--r--tests/bugs151/pr133298/DecA.java72
-rw-r--r--tests/bugs151/pr133298/DecA2.java62
2 files changed, 134 insertions, 0 deletions
diff --git a/tests/bugs151/pr133298/DecA.java b/tests/bugs151/pr133298/DecA.java
new file mode 100644
index 000000000..7be6a7b45
--- /dev/null
+++ b/tests/bugs151/pr133298/DecA.java
@@ -0,0 +1,72 @@
+import java.lang.annotation.Annotation;
+import java.lang.annotation.Retention;
+import java.lang.annotation.RetentionPolicy;
+import java.lang.reflect.Constructor;
+import java.lang.reflect.Field;
+import java.lang.reflect.Method;
+import java.util.ArrayList;
+import java.util.Collections;
+import java.util.Iterator;
+import java.util.List;
+
+
+@Retention(RetentionPolicy.RUNTIME) @interface One {}
+@Retention(RetentionPolicy.RUNTIME) @interface Two {}
+@Retention(RetentionPolicy.RUNTIME) @interface Three {}
+@Retention(RetentionPolicy.RUNTIME) @interface Four {}
+@Retention(RetentionPolicy.RUNTIME) @interface Five {}
+@Retention(RetentionPolicy.RUNTIME) @interface Six {}
+
+class Target {
+
+ public void m() {}
+
+ public Target(int i) {}
+
+ public int x;
+}
+
+aspect X {
+ declare @method: * Target.*(..): @One;
+ declare @method: * Target.*(..): @Two;
+
+
+ declare @constructor: Target.new(int): @Three;
+ declare @constructor: Target.new(int): @Four;
+
+
+ declare @field: int Target.*: @Five;
+ declare @field: int Target.*: @Six;
+}
+
+public class DecA {
+ public static void main(String []argv) {
+ // Let's do the method then the ctor, then the field
+ try {
+ Class c = Target.class;
+ Method m = c.getDeclaredMethod("m",null);
+ System.err.println("There are "+m.getAnnotations().length+" annotations on public void m():");
+ dumpAnnos(m.getAnnotations());
+ Constructor ctor = c.getDeclaredConstructor(new Class[]{Integer.TYPE});
+ System.err.println("There are "+ctor.getAnnotations().length+" annotations on public Target(int):");
+ dumpAnnos(ctor.getAnnotations());
+ Field f = c.getDeclaredField("x");
+ System.err.println("There are "+f.getAnnotations().length+" annotations on public int x:");
+ dumpAnnos(f.getAnnotations());
+ } catch (Exception e) { e.printStackTrace();}
+ }
+
+ public static void dumpAnnos(Annotation[] anns) {
+ List l = new ArrayList();
+ if (anns!=null) {
+ for (int i = 0; i < anns.length; i++) {
+ l.add(anns[i].annotationType().getName());
+ }
+ }
+ Collections.sort(l);
+ int i = 1;
+ for (Iterator iter = l.iterator(); iter.hasNext();) {
+ System.err.println((i++)+") "+iter.next());
+ }
+ }
+} \ No newline at end of file
diff --git a/tests/bugs151/pr133298/DecA2.java b/tests/bugs151/pr133298/DecA2.java
new file mode 100644
index 000000000..bb8728906
--- /dev/null
+++ b/tests/bugs151/pr133298/DecA2.java
@@ -0,0 +1,62 @@
+import java.lang.annotation.Annotation;
+import java.lang.annotation.Retention;
+import java.lang.annotation.RetentionPolicy;
+import java.lang.reflect.Constructor;
+import java.lang.reflect.Field;
+import java.lang.reflect.Method;
+import java.util.ArrayList;
+import java.util.Collections;
+import java.util.Iterator;
+import java.util.List;
+
+
+@Retention(RetentionPolicy.RUNTIME) @interface One {}
+@Retention(RetentionPolicy.RUNTIME) @interface Two {}
+@Retention(RetentionPolicy.RUNTIME) @interface Three {}
+@Retention(RetentionPolicy.RUNTIME) @interface Four {}
+@Retention(RetentionPolicy.RUNTIME) @interface Five {}
+@Retention(RetentionPolicy.RUNTIME) @interface Six {}
+
+interface Target {
+ public void m();
+}
+
+class A implements Target {
+ public void m() {
+
+ }
+}
+
+aspect X {
+ declare @method: * Target+.*(..): @One;
+ declare @method: * Target+.*(..): @Two;
+}
+
+public class DecA2 {
+ public static void main(String []argv) {
+ try {
+ Class c = Target.class;
+ Method m = c.getDeclaredMethod("m",null);
+ System.err.println("There are "+m.getAnnotations().length+" annotations on public void Target.m():");
+ dumpAnnos(m.getAnnotations());
+ c = A.class;
+ m = c.getDeclaredMethod("m",null);
+ System.err.println("There are "+m.getAnnotations().length+" annotations on public void A.m():");
+ dumpAnnos(m.getAnnotations());
+ } catch (Exception e) { e.printStackTrace();}
+ }
+
+ public static void dumpAnnos(Annotation[] anns) {
+ List l = new ArrayList();
+ if (anns!=null) {
+ for (int i = 0; i < anns.length; i++) {
+ l.add(anns[i].annotationType().getName());
+ }
+ }
+ Collections.sort(l);
+ int i = 1;
+ for (Iterator iter = l.iterator(); iter.hasNext();) {
+ System.err.println((i++)+") "+iter.next());
+ }
+ }
+} \ No newline at end of file