]> source.dussan.org Git - aspectj.git/commitdiff
287613/315820: testcode
authoraclement <aclement>
Fri, 18 Jun 2010 22:11:06 +0000 (22:11 +0000)
committeraclement <aclement>
Fri, 18 Jun 2010 22:11:06 +0000 (22:11 +0000)
tests/bugs169/pr287613/DAMethod1.java [new file with mode: 0644]
tests/bugs169/pr287613/DAMethod2.java [new file with mode: 0644]
tests/bugs169/pr287613/Decaf1.java [new file with mode: 0644]
tests/bugs169/pr287613/DeclareAnnot.java [new file with mode: 0644]
tests/bugs169/pr287613/DeclareAnnotMethodCtor.java [new file with mode: 0644]
tests/bugs169/pr287613/Target.java [new file with mode: 0644]
tests/bugs169/pr315820/MultiAnno.java [new file with mode: 0644]
tests/bugs169/pr315820/MultiAnno2.java [new file with mode: 0644]

diff --git a/tests/bugs169/pr287613/DAMethod1.java b/tests/bugs169/pr287613/DAMethod1.java
new file mode 100644 (file)
index 0000000..59e7f38
--- /dev/null
@@ -0,0 +1,16 @@
+import java.lang.annotation.*;
+
+@Retention(RetentionPolicy.RUNTIME)
+@interface Annot {}
+
+class Person {
+       public void foo() {}
+       public boolean bar() {return false;}
+       public String getString() { return null; }
+       public boolean isSet() { return false; }
+       public void isNotReturningBoolean() { }
+}
+
+aspect DAMethod1 {
+    declare @method: (* *.get*()) || (boolean *.is*()): @Annot;
+}
diff --git a/tests/bugs169/pr287613/DAMethod2.java b/tests/bugs169/pr287613/DAMethod2.java
new file mode 100644 (file)
index 0000000..600a662
--- /dev/null
@@ -0,0 +1,29 @@
+import java.lang.annotation.*;
+
+@Retention(RetentionPolicy.RUNTIME)
+@interface Annot {}
+
+@Retention(RetentionPolicy.RUNTIME)
+@interface Foo {}
+
+class Person {
+       @Foo
+       public void foo() {}
+       @Foo
+       public boolean bar() {return false;}
+       @Foo
+       public String getString() { return null; }
+       @Foo
+       public boolean isSet() { return false; }
+       @Foo
+       public void isNotReturningBoolean() { }
+
+       public void getin() {}
+}
+
+aspect DAMethod2 {
+
+    declare @method: !(* *.get*()) && !(* aspectOf(..)) && !(* hasAspect(..)): @Annot;
+    
+    declare @method: !@Foo * *(..) && !(* aspectOf(..)) && !(* hasAspect(..)): @Annot;
+}
diff --git a/tests/bugs169/pr287613/Decaf1.java b/tests/bugs169/pr287613/Decaf1.java
new file mode 100644 (file)
index 0000000..c4e5a64
--- /dev/null
@@ -0,0 +1,53 @@
+import java.lang.annotation.*;
+import java.lang.reflect.*;
+
+@Retention(RetentionPolicy.RUNTIME)
+@interface Annot1 {}
+@Retention(RetentionPolicy.RUNTIME)
+@interface Annot2 {}
+@Retention(RetentionPolicy.RUNTIME)
+@interface Annot3 {}
+
+class Target {
+  public static void main(String[] argv) throws Exception {
+         System.out.println("Field one");
+         printAnnotations(A.class.getDeclaredField("one"));
+         printAnnotations(B.class.getDeclaredField("one"));
+         System.out.println("Field two");
+         printAnnotations(A.class.getDeclaredField("two"));
+         printAnnotations(B.class.getDeclaredField("two"));
+         System.out.println("Field three");
+         printAnnotations(A.class.getDeclaredField("two"));
+         printAnnotations(B.class.getDeclaredField("two"));
+  }
+  
+  public static void printAnnotations(Field field) {
+         Annotation[] annos = field.getAnnotations();
+         if (annos==null || annos.length==0) {
+                 System.out.println("no annotations");
+         } else {
+                 for (Annotation anno: annos) {
+                         System.out.print(anno+" ");
+                 }
+                 System.out.println();
+         }
+  }
+}
+
+class A {
+       public int one;
+       public String two;
+       public float three;
+}
+
+class B {
+       public int one;
+       public String two;
+       public float three;
+}
+
+aspect DeclareAnnot {
+       declare @field: (int A.one) || (int B.one): @Annot1;
+       declare @field: (String two) && !(* B.*): @Annot2;
+       declare @field: !(* one) && !(* two): @Annot3;
+}
diff --git a/tests/bugs169/pr287613/DeclareAnnot.java b/tests/bugs169/pr287613/DeclareAnnot.java
new file mode 100644 (file)
index 0000000..d1b8aaa
--- /dev/null
@@ -0,0 +1,30 @@
+import java.lang.annotation.*;
+
+@Retention(RetentionPolicy.RUNTIME)
+@interface Annot {}
+
+aspect DeclareAnnot {
+//    declare @method: * *.get*() || boolean *.is*(): @Annot;
+
+//    declare @field: (String *.*) || (boolean *.*) : @Annot;
+//    declare @field: (String *.*) && (boolean *.*) : @Annot;
+//    declare @field: (String *.*) && !(boolean *.*) : @Annot;
+    declare @field: ((String *.*) || !(String *.*)) && !(boolean *.*) : @Annot;
+    declare @field: String *.* : @Annot;
+
+/*
+    declare @constructor: Person.new() || Person.new(*) : @Annot;
+
+    declare @method: * *.get*() && boolean *.is*(): @Annot;
+
+    declare @field: String *.* && boolean *.* : @Annot;
+
+    declare @constructor: Person.new() && Person.new(*) : @Annot;
+
+    declare @method: !(* *.get*()): @Annot;
+
+    declare @field: !(String *.*) : @Annot;
+
+    declare @constructor: !(Person.new()) : @Annot;
+*/
+}
diff --git a/tests/bugs169/pr287613/DeclareAnnotMethodCtor.java b/tests/bugs169/pr287613/DeclareAnnotMethodCtor.java
new file mode 100644 (file)
index 0000000..a9108cc
--- /dev/null
@@ -0,0 +1,24 @@
+import java.lang.annotation.*;
+
+@Retention(RetentionPolicy.RUNTIME)
+@interface Annot {}
+
+class Person {}
+aspect DeclareAnnot {
+    declare @constructor: (Person.new()) || (Person.new(*)) : @Annot;
+
+
+//    declare @method: (* *.get*()) && (boolean *.is*()): @Annot;
+
+/*
+    declare @field: String *.* && boolean *.* : @Annot;
+
+    declare @constructor: Person.new() && Person.new(*) : @Annot;
+
+    declare @method: !(* *.get*()): @Annot;
+
+    declare @field: !(String *.*) : @Annot;
+
+    declare @constructor: !(Person.new()) : @Annot;
+*/
+}
diff --git a/tests/bugs169/pr287613/Target.java b/tests/bugs169/pr287613/Target.java
new file mode 100644 (file)
index 0000000..d8b6471
--- /dev/null
@@ -0,0 +1,53 @@
+import java.lang.annotation.*;
+import java.lang.reflect.*;
+
+@Retention(RetentionPolicy.RUNTIME)
+@interface Annot1 {}
+@Retention(RetentionPolicy.RUNTIME)
+@interface Annot2 {}
+@Retention(RetentionPolicy.RUNTIME)
+@interface Annot3 {}
+
+public class Target {
+  public static void main(String[] argv) throws Exception {
+         System.out.println("Field one");
+         printAnnotations(A.class.getDeclaredField("one"));
+         printAnnotations(B.class.getDeclaredField("one"));
+         System.out.println("Field two");
+         printAnnotations(A.class.getDeclaredField("two"));
+         printAnnotations(B.class.getDeclaredField("two"));
+         System.out.println("Field three");
+         printAnnotations(A.class.getDeclaredField("three"));
+         printAnnotations(B.class.getDeclaredField("three"));
+  }
+  
+  public static void printAnnotations(Field field) {
+         Annotation[] annos = field.getAnnotations();
+         if (annos==null || annos.length==0) {
+                 System.out.println("no annotations");
+         } else {
+                 for (Annotation anno: annos) {
+                         System.out.print(anno+" ");
+                 }
+                 System.out.println();
+         }
+  }
+}
+
+class A {
+       public int one;
+       public String two;
+       public float three;
+}
+
+class B {
+       public int one;
+       public String two;
+       public float three;
+}
+
+aspect DeclareAnnot {
+       declare @field: (int A.one) || (int B.one): @Annot1;
+       declare @field: (String two) && !(* B.*): @Annot2;
+       declare @field: !(* one) && !(* two): @Annot3;
+}
diff --git a/tests/bugs169/pr315820/MultiAnno.java b/tests/bugs169/pr315820/MultiAnno.java
new file mode 100644 (file)
index 0000000..8916c7c
--- /dev/null
@@ -0,0 +1,26 @@
+import java.lang.annotation.*;
+
+@Retention(RetentionPolicy.RUNTIME)
+@interface Foo {}
+
+@Retention(RetentionPolicy.RUNTIME)
+@interface Bar {
+  String value() default "abc";
+}
+
+aspect A {
+  declare @method: void MultiAnno.m(): @Foo @Bar;
+  declare @field: int MultiAnno.i: @Bar @Foo;
+  declare @type: MultiAnno: @Bar("ABC") @Foo;
+  declare @constructor: MultiAnno.new(): @Foo @Bar("def");
+}
+
+public class MultiAnno {
+  public MultiAnno() {}
+  public int i;
+  public static void main(String[]argv) throws Exception {
+    System.out.println(MultiAnno.class.getDeclaredMethod("m").getAnnotations()[0]);
+  }
+  public void m() {
+  }
+}
diff --git a/tests/bugs169/pr315820/MultiAnno2.java b/tests/bugs169/pr315820/MultiAnno2.java
new file mode 100644 (file)
index 0000000..e771983
--- /dev/null
@@ -0,0 +1,32 @@
+import java.lang.annotation.*;
+
+@Retention(RetentionPolicy.RUNTIME)
+@interface Foo {}
+
+@Retention(RetentionPolicy.RUNTIME)
+@interface Bar {
+  String value() default "abc";
+}
+
+@Retention(RetentionPolicy.RUNTIME)
+@interface Goo {
+  int value() default 44;
+}
+
+aspect A {
+//  declare @method: void MultiAnno.m(): @Foo @Bar;
+  declare @field: int MultiAnno2.i: @Bar("XYCZ") @Foo @Goo(23);
+//  declare @type: MultiAnno: @Bar("ABC") @Foo;
+//  declare @constructor: MultiAnno.new(): @Foo @Bar("def");
+}
+
+public class MultiAnno2 {
+  public MultiAnno2() {}
+  public int i;
+  public static void main(String[]argv) throws Exception {
+    System.out.println(MultiAnno2.class.getDeclaredField("i").getAnnotations()[0]);
+    System.out.println(MultiAnno2.class.getDeclaredField("i").getAnnotations()[1]);
+  }
+  public void m() {
+  }
+}