]> source.dussan.org Git - aspectj.git/commitdiff
Declare annotation: tons of testcode
authoraclement <aclement>
Thu, 10 Mar 2005 11:58:28 +0000 (11:58 +0000)
committeraclement <aclement>
Thu, 10 Mar 2005 11:58:28 +0000 (11:58 +0000)
48 files changed:
tests/java5/annotations/declare/AnnotatedType.java [new file with mode: 0644]
tests/java5/annotations/declare/BaseTypes.java [new file with mode: 0644]
tests/java5/annotations/declare/BaseTypes2.java [new file with mode: 0644]
tests/java5/annotations/declare/Colored.java [new file with mode: 0644]
tests/java5/annotations/declare/DeathByAnnotations.aj [new file with mode: 0644]
tests/java5/annotations/declare/DecaDecpInteractions1.aj [new file with mode: 0644]
tests/java5/annotations/declare/DecaDecpInteractions2.aj [new file with mode: 0644]
tests/java5/annotations/declare/DecaDecpInteractions3.aj [new file with mode: 0644]
tests/java5/annotations/declare/DecaDecpInteractions4.aj [new file with mode: 0644]
tests/java5/annotations/declare/DecaType1.java [new file with mode: 0644]
tests/java5/annotations/declare/DecaType2.java [new file with mode: 0644]
tests/java5/annotations/declare/DecaType3.java [new file with mode: 0644]
tests/java5/annotations/declare/DecaTypeBin1.aj [new file with mode: 0644]
tests/java5/annotations/declare/DecaTypeBin2.aj [new file with mode: 0644]
tests/java5/annotations/declare/DecaTypeBin3.aj [new file with mode: 0644]
tests/java5/annotations/declare/DecaTypeBin4.aj [new file with mode: 0644]
tests/java5/annotations/declare/DecaTypeBin5.aj [new file with mode: 0644]
tests/java5/annotations/declare/DecaTypeBin6.aj [new file with mode: 0644]
tests/java5/annotations/declare/DecaTypeBin7.aj [new file with mode: 0644]
tests/java5/annotations/declare/DecaTypeBin8.aj [new file with mode: 0644]
tests/java5/annotations/declare/DecaTypeBin9.aj [new file with mode: 0644]
tests/java5/annotations/declare/EnumAndClassValues.aj [new file with mode: 0644]
tests/java5/annotations/declare/FunkyAnnotations.java [new file with mode: 0644]
tests/java5/annotations/declare/Temp.java [new file with mode: 0644]
tests/java5/annotations/declare/atfield/AtField1.aj [new file with mode: 0644]
tests/java5/annotations/declare/atfield/Base.java [new file with mode: 0644]
tests/java5/annotations/declare/atfield/Colored.java [new file with mode: 0644]
tests/java5/annotations/declare/atfield/Fruit.java [new file with mode: 0644]
tests/java5/annotations/declare/atfield/RecursiveFields.aj [new file with mode: 0644]
tests/java5/annotations/declare/atfield/RecursiveFields2.aj [new file with mode: 0644]
tests/java5/annotations/declare/atfield/RightTarget.aj [new file with mode: 0644]
tests/java5/annotations/declare/atfield/TwoOnOneField.aj [new file with mode: 0644]
tests/java5/annotations/declare/atfield/TwoOnOneField2.aj [new file with mode: 0644]
tests/java5/annotations/declare/atfield/WrongTarget.aj [new file with mode: 0644]
tests/java5/annotations/declare/atfield/ignoreTypeNotExposed.properties [new file with mode: 0644]
tests/java5/annotations/declare/atmethodctor/AtCtor1.aj [new file with mode: 0644]
tests/java5/annotations/declare/atmethodctor/AtMethod1.aj [new file with mode: 0644]
tests/java5/annotations/declare/atmethodctor/Base.class [new file with mode: 0644]
tests/java5/annotations/declare/atmethodctor/Base.java [new file with mode: 0644]
tests/java5/annotations/declare/atmethodctor/Colored.class [new file with mode: 0644]
tests/java5/annotations/declare/atmethodctor/Colored.java [new file with mode: 0644]
tests/java5/annotations/declare/atmethodctor/Fruit.java [new file with mode: 0644]
tests/java5/annotations/declare/atmethodctor/RightTarget.aj [new file with mode: 0644]
tests/java5/annotations/declare/atmethodctor/TwoOnOneMember.aj [new file with mode: 0644]
tests/java5/annotations/declare/atmethodctor/TwoOnOneMember2.aj [new file with mode: 0644]
tests/java5/annotations/declare/atmethodctor/WrongTarget.aj [new file with mode: 0644]
tests/java5/annotations/declare/atmethodctor/ignoreTypeNotExposed.properties [new file with mode: 0644]
tests/java5/annotations/declare/ignoreTypeNotExposed.properties [new file with mode: 0644]

diff --git a/tests/java5/annotations/declare/AnnotatedType.java b/tests/java5/annotations/declare/AnnotatedType.java
new file mode 100644 (file)
index 0000000..ab76aad
--- /dev/null
@@ -0,0 +1,14 @@
+import java.lang.annotation.*;
+
+@Retention(RetentionPolicy.RUNTIME) @interface Color { String value();} 
+
+@Color("red")
+public class AnnotatedType {
+  public static void main(String[] argv) {
+    new AnnotatedType().m();
+  }
+
+  public void m() {
+    System.err.println("m() running");
+  }
+}
diff --git a/tests/java5/annotations/declare/BaseTypes.java b/tests/java5/annotations/declare/BaseTypes.java
new file mode 100644 (file)
index 0000000..153d545
--- /dev/null
@@ -0,0 +1,19 @@
+public class BaseTypes {
+
+  public static void main(String []argv) {
+    new A().m();
+    new B().m();
+    new C().m();
+  }
+
+}
+
+class A {
+  public void m() { System.err.println("A.m() running");}
+}
+
+class B extends A{
+}
+
+class C extends B{
+}
diff --git a/tests/java5/annotations/declare/BaseTypes2.java b/tests/java5/annotations/declare/BaseTypes2.java
new file mode 100644 (file)
index 0000000..153d545
--- /dev/null
@@ -0,0 +1,19 @@
+public class BaseTypes {
+
+  public static void main(String []argv) {
+    new A().m();
+    new B().m();
+    new C().m();
+  }
+
+}
+
+class A {
+  public void m() { System.err.println("A.m() running");}
+}
+
+class B extends A{
+}
+
+class C extends B{
+}
diff --git a/tests/java5/annotations/declare/Colored.java b/tests/java5/annotations/declare/Colored.java
new file mode 100644 (file)
index 0000000..0ec387c
--- /dev/null
@@ -0,0 +1,3 @@
+import java.lang.annotation.*;
+
+@Retention(RetentionPolicy.RUNTIME) public  @interface Colored {String value();}
diff --git a/tests/java5/annotations/declare/DeathByAnnotations.aj b/tests/java5/annotations/declare/DeathByAnnotations.aj
new file mode 100644 (file)
index 0000000..7e04aed
--- /dev/null
@@ -0,0 +1,36 @@
+package p.q;
+import java.lang.annotation.*;
+
+
+@Retention(RetentionPolicy.RUNTIME) @interface Colored {String value();}
+@Retention(RetentionPolicy.RUNTIME) @interface Fruit {String value();}
+@Retention(RetentionPolicy.RUNTIME) @interface Material {String value();}
+
+aspect AllTogether {
+
+  declare @type: DeathByAnnotations: @Colored("red");
+  declare @method: * m*(..): @Fruit("tomato");
+  declare @constructor: DeathByAnnotations.new(..): @Fruit("tomato");
+
+  declare @field: * DeathByAnnotations.*: @Material("wood");
+
+}
+
+public class DeathByAnnotations {
+  int i;
+  static String s;
+
+  public static void main(String[]argv) {
+    new DeathByAnnotations().i = 3;
+    s = "hello";
+    new DeathByAnnotations().m1();
+    new DeathByAnnotations(3).m2();
+  }
+
+  public DeathByAnnotations() {}
+  public DeathByAnnotations(int i) {}
+
+  public void m1() {}
+  public void m2() {}
+
+}
diff --git a/tests/java5/annotations/declare/DecaDecpInteractions1.aj b/tests/java5/annotations/declare/DecaDecpInteractions1.aj
new file mode 100644 (file)
index 0000000..22f60ff
--- /dev/null
@@ -0,0 +1,23 @@
+import java.lang.annotation.*;
+
+interface Marker {}
+
+@Retention(RetentionPolicy.RUNTIME) @interface Color { String value();}
+
+// Color put on a particular type, marker interface added to any types with Color annotation
+// Deca specified first
+public aspect DecaDecpInteractions1 {
+
+  declare @type: A : @Color("red");
+
+  declare parents: @Color *  implements Marker;
+}
+
+aspect X {
+  before(): execution(* *(..)) && this(Marker) {
+    System.err.println("Marker interface identified on "+thisJoinPoint);
+  }
+  before(): execution(* *(..)) && @this(Color) {
+    System.err.println("Color annotation identified on "+thisJoinPoint);
+  }
+}
diff --git a/tests/java5/annotations/declare/DecaDecpInteractions2.aj b/tests/java5/annotations/declare/DecaDecpInteractions2.aj
new file mode 100644 (file)
index 0000000..2009459
--- /dev/null
@@ -0,0 +1,23 @@
+import java.lang.annotation.*;
+
+interface Marker {}
+
+@Retention(RetentionPolicy.RUNTIME) @interface Color { String value();}
+
+// Color put on a particular type, marker interface added to any types with Color annotation
+// Decp specified first
+public aspect DecaDecpInteractions2 {
+
+  declare parents: @Color *  implements Marker;
+
+  declare @type: A : @Color("red");
+}
+
+aspect X {
+  before(): execution(* *(..)) && this(Marker) {
+    System.err.println("Marker interface identified on "+thisJoinPoint);
+  }
+  before(): execution(* *(..)) && @this(Color) {
+    System.err.println("Color annotation identified on "+thisJoinPoint);
+  }
+}
diff --git a/tests/java5/annotations/declare/DecaDecpInteractions3.aj b/tests/java5/annotations/declare/DecaDecpInteractions3.aj
new file mode 100644 (file)
index 0000000..6002c93
--- /dev/null
@@ -0,0 +1,24 @@
+import java.lang.annotation.*;
+
+interface Marker {}
+
+@Retention(RetentionPolicy.RUNTIME) @interface Color { String value();}
+
+// Put the marker interface on a particular type and add the annotation on 
+// types with that interface.
+// deca specified first
+public aspect DecaDecpInteractions3 {
+
+  declare @type: Marker+ : @Color("red");
+
+  declare parents: A* implements Marker;
+}
+
+aspect X {
+  before(): execution(* *(..)) && this(Marker) {
+    System.err.println("Marker interface identified on "+thisJoinPoint);
+  }
+  before(): execution(* *(..)) && @this(Color) {
+    System.err.println("Color annotation identified on "+thisJoinPoint);
+  }
+}
diff --git a/tests/java5/annotations/declare/DecaDecpInteractions4.aj b/tests/java5/annotations/declare/DecaDecpInteractions4.aj
new file mode 100644 (file)
index 0000000..4e44274
--- /dev/null
@@ -0,0 +1,24 @@
+import java.lang.annotation.*;
+
+interface Marker {}
+
+@Retention(RetentionPolicy.RUNTIME) @interface Color { String value();}
+
+// Put the marker interface on a particular type and add the annotation on 
+// types with that interface.
+// decp specified first
+public aspect DecaDecpInteractions4 {
+
+  declare parents: A* implements Marker;
+
+  declare @type: Marker+ : @Color("red");
+}
+
+aspect X {
+  before(): execution(* *(..)) && this(Marker) {
+    System.err.println("Marker interface identified on "+thisJoinPoint);
+  }
+  before(): execution(* *(..)) && @this(Color) {
+    System.err.println("Color annotation identified on "+thisJoinPoint);
+  }
+}
diff --git a/tests/java5/annotations/declare/DecaType1.java b/tests/java5/annotations/declare/DecaType1.java
new file mode 100644 (file)
index 0000000..ed0707e
--- /dev/null
@@ -0,0 +1,15 @@
+import java.lang.annotation.*;
+
+public class DecaType1 {
+  public static void main(String[] argv) {
+       Annotation a = DecaType1.class.getAnnotation(MyAnnotation.class);
+        System.err.println("annotation is "+a);
+  }
+}
+
+aspect X {
+  declare @type: DecaType1 : @MyAnnotation;
+}
+
+@java.lang.annotation.Retention(java.lang.annotation.RetentionPolicy.RUNTIME)
+@interface MyAnnotation {}
diff --git a/tests/java5/annotations/declare/DecaType2.java b/tests/java5/annotations/declare/DecaType2.java
new file mode 100644 (file)
index 0000000..19306da
--- /dev/null
@@ -0,0 +1,20 @@
+import java.lang.annotation.*;
+
+public class DecaType2 {
+  public static void main(String[] argv) {
+       Annotation a = DecaType2.class.getAnnotation(MyAnnotation.class);
+        System.err.println("annotation on DecaType2 is "+a);
+       a = X.class.getAnnotation(MyAnnotation.class);
+        System.err.println("annotation on X is "+a);
+       a = MyAnnotation.class.getAnnotation(MyAnnotation.class);
+        System.err.println("annotation on MyAnnotation is "+a);
+  }
+}
+
+aspect X {
+  declare @type: * : @MyAnnotation;
+}
+
+@java.lang.annotation.Retention(java.lang.annotation.RetentionPolicy.RUNTIME)
+@interface MyAnnotation {}
+
diff --git a/tests/java5/annotations/declare/DecaType3.java b/tests/java5/annotations/declare/DecaType3.java
new file mode 100644 (file)
index 0000000..4a80ba3
--- /dev/null
@@ -0,0 +1,21 @@
+import java.lang.annotation.*;
+
+public class DecaType3 {
+  public static void main(String[] argv) {
+    new DecaType3().sayhello();
+  }
+  public void sayhello() {
+    System.err.println("hello world");
+  }
+}
+
+aspect X {
+  declare @type: DecaType3 : @MyAnnotation;
+
+  after(): call(* println(..)) && @this(MyAnnotation) {
+    System.err.println("advice running");
+  }
+}
+
+@java.lang.annotation.Retention(java.lang.annotation.RetentionPolicy.RUNTIME)
+@interface MyAnnotation {}
diff --git a/tests/java5/annotations/declare/DecaTypeBin1.aj b/tests/java5/annotations/declare/DecaTypeBin1.aj
new file mode 100644 (file)
index 0000000..57a2ac6
--- /dev/null
@@ -0,0 +1,10 @@
+
+public aspect DecaTypeBin1 {
+  declare @type: A : @Colored("red");
+}
+
+aspect X {
+  before(): execution(* *(..)) && @this(Colored) {
+    System.err.println("Color identified on "+this.getClass());
+  }
+}
diff --git a/tests/java5/annotations/declare/DecaTypeBin2.aj b/tests/java5/annotations/declare/DecaTypeBin2.aj
new file mode 100644 (file)
index 0000000..c43877c
--- /dev/null
@@ -0,0 +1,23 @@
+import java.lang.annotation.*;
+
+@Retention(RetentionPolicy.RUNTIME) @interface ComplexAnnotation {
+  int ival();
+  byte bval();
+  char cval();
+  long jval();
+  double dval();
+  boolean zval();
+  short sval();
+  float fval();
+  String s();
+}
+
+public aspect DecaTypeBin2 {
+  declare @type: A : @ComplexAnnotation(ival=4,bval=2,cval=5,fval=3.0f,dval=33.4,zval=false,jval=56,sval=99,s="s");
+}
+
+aspect X {
+  before(): execution(* *(..)) && @this(ComplexAnnotation) {
+    System.err.println("ComplexAnnotation identified on "+thisJoinPoint);
+  }
+}
diff --git a/tests/java5/annotations/declare/DecaTypeBin3.aj b/tests/java5/annotations/declare/DecaTypeBin3.aj
new file mode 100644 (file)
index 0000000..70c402c
--- /dev/null
@@ -0,0 +1,19 @@
+import java.lang.annotation.*;
+
+@Retention(RetentionPolicy.RUNTIME) @interface Color { String value();} 
+@Retention(RetentionPolicy.RUNTIME) @interface Fruit { String value();} 
+
+public aspect DecaTypeBin3 {
+  declare @type: A : @Color("Yellow");
+  declare @type: A : @Fruit("Banana");
+}
+
+aspect X {
+  before(): execution(* *(..)) && @this(Color) {
+    System.err.println("Color identified on "+thisJoinPoint);
+  }
+
+  before(): execution(* *(..)) && @this(Fruit) {
+    System.err.println("Fruit identified on "+thisJoinPoint);
+  }
+}
diff --git a/tests/java5/annotations/declare/DecaTypeBin4.aj b/tests/java5/annotations/declare/DecaTypeBin4.aj
new file mode 100644 (file)
index 0000000..85684e1
--- /dev/null
@@ -0,0 +1,17 @@
+import java.lang.annotation.*;
+
+@Retention(RetentionPolicy.RUNTIME) @interface Fruit { String value();} 
+
+public aspect DecaTypeBin4 {
+  declare @type: AnnotatedType : @Fruit("Banana");
+}
+
+aspect X {
+  before(): execution(* *(..)) && @this(Color) {
+    System.err.println("Color identified on "+thisJoinPoint);
+  }
+
+  before(): execution(* *(..)) && @this(Fruit) {
+    System.err.println("Fruit identified on "+thisJoinPoint);
+  }
+}
diff --git a/tests/java5/annotations/declare/DecaTypeBin5.aj b/tests/java5/annotations/declare/DecaTypeBin5.aj
new file mode 100644 (file)
index 0000000..8fef8bb
--- /dev/null
@@ -0,0 +1,34 @@
+// Putting the wrong annotations onto types
+import java.lang.annotation.*;
+
+@Retention(RetentionPolicy.RUNTIME) @Target(ElementType.TYPE) @interface ColorT { String value();} 
+@Retention(RetentionPolicy.RUNTIME) @Target(ElementType.METHOD) @interface ColorM { String value();} 
+@Retention(RetentionPolicy.RUNTIME) @Target(ElementType.CONSTRUCTOR) @interface ColorC { String value();} 
+@Retention(RetentionPolicy.RUNTIME) @Target(ElementType.ANNOTATION_TYPE) @interface ColorA { String value();} 
+@Retention(RetentionPolicy.RUNTIME) @Target(ElementType.FIELD) @interface ColorF { String value();} 
+@Retention(RetentionPolicy.RUNTIME) @Target(ElementType.PARAMETER) @interface ColorP { String value();} 
+@Retention(RetentionPolicy.RUNTIME) @Target(ElementType.LOCAL_VARIABLE) @interface ColorL { String value();} 
+@Retention(RetentionPolicy.RUNTIME) @Target(ElementType.PACKAGE) @interface ColorPkg { String value();} 
+
+public aspect DecaTypeBin5 {
+  declare @type: A : @ColorT("Red");
+  declare @type: A : @ColorM("Orange");
+  declare @type: A : @ColorC("Yellow");
+  declare @type: A : @ColorA("Green");
+  declare @type: A : @ColorF("Blue");
+  declare @type: A : @ColorP("Indigo");
+  declare @type: A : @ColorL("Violet");
+  declare @type: A : @ColorPkg("White");
+}
+
+aspect X {
+  before(): execution(* *(..)) && @this(ColorT) { System.err.println("ColorT identified on "+thisJoinPoint); }
+  before(): execution(* *(..)) && @this(ColorM) { System.err.println("ColorM identified on "+thisJoinPoint); }
+  before(): execution(* *(..)) && @this(ColorC) { System.err.println("ColorC identified on "+thisJoinPoint); }
+  before(): execution(* *(..)) && @this(ColorA) { System.err.println("ColorA identified on "+thisJoinPoint); }
+  before(): execution(* *(..)) && @this(ColorF) { System.err.println("ColorF identified on "+thisJoinPoint); }
+  before(): execution(* *(..)) && @this(ColorP) { System.err.println("ColorP identified on "+thisJoinPoint); }
+  before(): execution(* *(..)) && @this(ColorL) { System.err.println("ColorL identified on "+thisJoinPoint); }
+  before(): execution(* *(..)) && @this(ColorPkg) { System.err.println("ColorPkg identified on "+thisJoinPoint); }
+
+}
diff --git a/tests/java5/annotations/declare/DecaTypeBin6.aj b/tests/java5/annotations/declare/DecaTypeBin6.aj
new file mode 100644 (file)
index 0000000..bee04bc
--- /dev/null
@@ -0,0 +1,30 @@
+// Putting the wrong annotations on types but specifying patterns as the target
+// rather than exact types
+import java.lang.annotation.*;
+
+@Retention(RetentionPolicy.RUNTIME) @Target(ElementType.TYPE) @interface ColorT { String value();} 
+@Retention(RetentionPolicy.RUNTIME) @Target(ElementType.METHOD) @interface ColorM { String value();} 
+@Retention(RetentionPolicy.RUNTIME) @Target(ElementType.CONSTRUCTOR) @interface ColorC { String value();} 
+@Retention(RetentionPolicy.RUNTIME) @Target(ElementType.FIELD) @interface ColorF { String value();} 
+@Retention(RetentionPolicy.RUNTIME) @Target(ElementType.PARAMETER) @interface ColorP { String value();} 
+@Retention(RetentionPolicy.RUNTIME) @Target(ElementType.LOCAL_VARIABLE) @interface ColorL { String value();} 
+@Retention(RetentionPolicy.RUNTIME) @Target(ElementType.PACKAGE) @interface ColorPkg { String value();} 
+
+public aspect DecaTypeBin6 {
+  declare @type: A+ : @ColorT("Red");
+  declare @type: A* : @ColorM("Orange");
+  declare @type: *A : @ColorC("Yellow");
+  declare @type: *A+ : @ColorL("Green");
+  declare @type: @ColorT * : @ColorF("Blue"); // also checks we loop correctly...
+}
+
+aspect X {
+  before(): execution(* *(..)) && @this(ColorT) { System.err.println("ColorT identified on "+thisJoinPoint); }
+  before(): execution(* *(..)) && @this(ColorM) { System.err.println("ColorM identified on "+thisJoinPoint); }
+  before(): execution(* *(..)) && @this(ColorC) { System.err.println("ColorC identified on "+thisJoinPoint); }
+  before(): execution(* *(..)) && @this(ColorF) { System.err.println("ColorF identified on "+thisJoinPoint); }
+  before(): execution(* *(..)) && @this(ColorP) { System.err.println("ColorP identified on "+thisJoinPoint); }
+  before(): execution(* *(..)) && @this(ColorL) { System.err.println("ColorL identified on "+thisJoinPoint); }
+  before(): execution(* *(..)) && @this(ColorPkg) { System.err.println("ColorPkg identified on "+thisJoinPoint); }
+
+}
diff --git a/tests/java5/annotations/declare/DecaTypeBin7.aj b/tests/java5/annotations/declare/DecaTypeBin7.aj
new file mode 100644 (file)
index 0000000..db625b6
--- /dev/null
@@ -0,0 +1,34 @@
+// Putting the wrong annotations on types but specifying patterns as the target
+// rather than exact types
+import java.lang.annotation.*;
+
+@Retention(RetentionPolicy.RUNTIME) @interface Color { String value();} 
+@Retention(RetentionPolicy.RUNTIME) @interface Fruit { String value();} 
+@Retention(RetentionPolicy.RUNTIME) @interface Chocolate { String value();} 
+
+interface M1 {}
+interface M2 {}
+interface M3 {}
+
+// sick and twisted
+public aspect DecaTypeBin7 {
+  declare parents: @Chocolate * implements M3;
+  declare @type: A : @Color("Red");
+  declare @type: M1+ : @Fruit("Banana");
+  declare parents: @Color * implements M1;
+  declare @type: M2+ : @Chocolate("maltesers");
+  declare parents: @Fruit * implements M2;
+
+  public void B.m() { System.err.println("B.m() running"); }
+  public void C.m() { System.err.println("C.m() running"); }
+}
+
+aspect X {
+  before(): execution(* *(..)) && @this(Color) { System.err.println("Color identified on "+thisJoinPoint); }
+  before(): execution(* *(..)) && @this(Fruit) { System.err.println("Fruit identified on "+thisJoinPoint); }
+  before(): execution(* *(..)) && @this(Chocolate) { System.err.println("Chocolate identified on "+thisJoinPoint); }
+  before(): execution(* *(..)) && target(M1) { System.err.println("M1 at "+thisJoinPoint); }
+  before(): execution(* *(..)) && target(M2) { System.err.println("M2 at "+thisJoinPoint); }
+  before(): execution(* *(..)) && target(M3) { System.err.println("M3 at "+thisJoinPoint); }
+
+}
diff --git a/tests/java5/annotations/declare/DecaTypeBin8.aj b/tests/java5/annotations/declare/DecaTypeBin8.aj
new file mode 100644 (file)
index 0000000..c777c83
--- /dev/null
@@ -0,0 +1,10 @@
+import java.lang.annotation.*;
+
+@Retention(RetentionPolicy.RUNTIME) @Target(ElementType.TYPE) @interface ColorT { String value();} 
+@Retention(RetentionPolicy.RUNTIME) @Target(ElementType.ANNOTATION_TYPE) @interface ColorA { String value();} 
+
+public aspect DecaTypeBin8 {
+  declare @type: A : @ColorT("Red");
+  declare @type: A : @ColorA("Green");
+}
+
diff --git a/tests/java5/annotations/declare/DecaTypeBin9.aj b/tests/java5/annotations/declare/DecaTypeBin9.aj
new file mode 100644 (file)
index 0000000..f875df1
--- /dev/null
@@ -0,0 +1,10 @@
+import java.lang.annotation.*;
+
+@Retention(RetentionPolicy.RUNTIME) @Target(ElementType.TYPE) @interface ColorT { String value();} 
+@Retention(RetentionPolicy.RUNTIME) @Target(ElementType.ANNOTATION_TYPE) @interface ColorA { String value();} 
+
+public aspect DecaTypeBin9 {
+  declare @type: A* : @ColorT("Red");
+  declare @type: A* : @ColorA("Green");
+}
+
diff --git a/tests/java5/annotations/declare/EnumAndClassValues.aj b/tests/java5/annotations/declare/EnumAndClassValues.aj
new file mode 100644 (file)
index 0000000..9090a01
--- /dev/null
@@ -0,0 +1,27 @@
+import java.lang.annotation.*;
+
+enum SimpleEnum { Red,Orange,Yellow,Green,Blue,Indigo,Violet };
+
+@Retention(RetentionPolicy.RUNTIME)
+@interface AnnotationEnumElement {
+  SimpleEnum enumval();
+}
+
+@Retention(RetentionPolicy.RUNTIME)
+@interface AnnotationClassElement {
+  Class clz();
+}
+
+
+aspect AnnotatedWithEnumClass {
+  declare @type: FunkyAnnotations : @AnnotationEnumElement(enumval=SimpleEnum.Red);
+  declare @type: FunkyAnnotations : @AnnotationClassElement(clz=Integer.class);
+
+  before(AnnotationEnumElement aee): call(* *(..)) && @target(aee) {
+    System.err.println("advice running: "+aee.enumval());
+  }
+
+  before(AnnotationClassElement ace): call(* *(..)) && @target(ace) {
+    System.err.println("advice running: "+ace.clz());
+  }
+}
diff --git a/tests/java5/annotations/declare/FunkyAnnotations.java b/tests/java5/annotations/declare/FunkyAnnotations.java
new file mode 100644 (file)
index 0000000..91460e4
--- /dev/null
@@ -0,0 +1,9 @@
+public class FunkyAnnotations {
+
+  public static void main(String[] argv) {
+    new FunkyAnnotations().m();
+  }
+  public void m() {
+    System.err.println("method running");
+  }
+}
diff --git a/tests/java5/annotations/declare/Temp.java b/tests/java5/annotations/declare/Temp.java
new file mode 100644 (file)
index 0000000..c425366
--- /dev/null
@@ -0,0 +1,13 @@
+import java.lang.annotation.*;
+
+enum SimpleEnum { Red,Orange,Yellow,Green,Blue,Indigo,Violet };
+
+@Retention(RetentionPolicy.RUNTIME)
+@interface AnnotationEnumElement {
+  SimpleEnum enumval();
+}
+
+
+@AnnotationEnumElement(enumval=SimpleEnum.Red)
+class C {
+}
diff --git a/tests/java5/annotations/declare/atfield/AtField1.aj b/tests/java5/annotations/declare/atfield/AtField1.aj
new file mode 100644 (file)
index 0000000..98cda93
--- /dev/null
@@ -0,0 +1,11 @@
+//Simple declare annotation attached to a field
+public aspect AtField1 {
+ declare @field: public int * : @Colored("red");
+ declare parents: AtField1 implements java.io.Serializable;
+}
+
+aspect X {
+  before(): set(@Colored * *) {
+    System.err.println("Colored field access at "+thisJoinPoint);
+  }
+}
diff --git a/tests/java5/annotations/declare/atfield/Base.java b/tests/java5/annotations/declare/atfield/Base.java
new file mode 100644 (file)
index 0000000..354c622
--- /dev/null
@@ -0,0 +1,23 @@
+import java.util.*;
+
+public class Base {
+
+  public int publicIntField;
+
+  private String privateStringField;
+
+  public List publicListField;
+
+  protected List protectedListField;
+
+  public static void main(String[]argv) {
+    new Base().x();
+  }
+
+  public void x() {
+    publicIntField     = 1;
+    privateStringField = "aaa";
+    publicListField = new ArrayList();
+    protectedListField = new ArrayList();
+  }
+}
diff --git a/tests/java5/annotations/declare/atfield/Colored.java b/tests/java5/annotations/declare/atfield/Colored.java
new file mode 100644 (file)
index 0000000..01feb0c
--- /dev/null
@@ -0,0 +1,2 @@
+import java.lang.annotation.*; 
+@Retention(RetentionPolicy.RUNTIME) public @interface Colored {String value();}
diff --git a/tests/java5/annotations/declare/atfield/Fruit.java b/tests/java5/annotations/declare/atfield/Fruit.java
new file mode 100644 (file)
index 0000000..78d60bb
--- /dev/null
@@ -0,0 +1,2 @@
+import java.lang.annotation.*; 
+@Retention(RetentionPolicy.RUNTIME) public @interface Fruit {String value();}
diff --git a/tests/java5/annotations/declare/atfield/RecursiveFields.aj b/tests/java5/annotations/declare/atfield/RecursiveFields.aj
new file mode 100644 (file)
index 0000000..46eae71
--- /dev/null
@@ -0,0 +1,11 @@
+// check order of application - this should work
+public aspect RecursiveFields {
+  declare @field: public int * : @Colored("blue");
+  declare @field: @Colored * * : @Fruit("orange");
+}
+
+aspect X {
+  before(): set(@Fruit * *) {
+    System.err.println("Fruit field access at "+thisJoinPoint);
+  }
+}
diff --git a/tests/java5/annotations/declare/atfield/RecursiveFields2.aj b/tests/java5/annotations/declare/atfield/RecursiveFields2.aj
new file mode 100644 (file)
index 0000000..b695e08
--- /dev/null
@@ -0,0 +1,11 @@
+// check order of application - this should work
+public aspect RecursiveFields2 {
+  declare @field: @Colored * * : @Fruit("orange");
+  declare @field: public int * : @Colored("blue");
+}
+
+aspect X {
+  before(): set(@Fruit * *) {
+    System.err.println("Fruit field access at "+thisJoinPoint);
+  }
+}
diff --git a/tests/java5/annotations/declare/atfield/RightTarget.aj b/tests/java5/annotations/declare/atfield/RightTarget.aj
new file mode 100644 (file)
index 0000000..9a8d2c3
--- /dev/null
@@ -0,0 +1,14 @@
+// trying to put annotations on that correctly use @Target
+import java.lang.annotation.*;
+
+@Retention(RetentionPolicy.RUNTIME) @Target(ElementType.FIELD) @interface FieldColoring { String value(); }
+
+public aspect RightTarget {
+  declare @field: public int * : @FieldColoring("red");
+}
+
+aspect X {
+  before(): set(@FieldColoring * *) {
+    System.err.println("Colored field access at "+thisJoinPoint);
+  }
+}
diff --git a/tests/java5/annotations/declare/atfield/TwoOnOneField.aj b/tests/java5/annotations/declare/atfield/TwoOnOneField.aj
new file mode 100644 (file)
index 0000000..d0f37b6
--- /dev/null
@@ -0,0 +1,11 @@
+// trying to put two annotations onto one field
+public aspect TwoOnOneField {
+  declare @field: public int * : @Colored("red");
+  declare @field: public int * : @Colored("blue");
+}
+
+aspect X {
+  before(): set(@Colored * *) {
+    System.err.println("Colored field access at "+thisJoinPoint);
+  }
+}
diff --git a/tests/java5/annotations/declare/atfield/TwoOnOneField2.aj b/tests/java5/annotations/declare/atfield/TwoOnOneField2.aj
new file mode 100644 (file)
index 0000000..d886eb2
--- /dev/null
@@ -0,0 +1,14 @@
+// trying to put two annotations onto one field - should be OK, they are diff annotations
+public aspect TwoOnOneField2 {
+  declare @field: public int * : @Colored("yellow");
+  declare @field: public int * : @Fruit("banana");
+}
+
+aspect X {
+  before(): set(@Colored * *) {
+    System.err.println("Colored field access at "+thisJoinPoint);
+  }
+  before(): set(@Fruit * *) {
+    System.err.println("Fruit field access at "+thisJoinPoint);
+  }
+}
diff --git a/tests/java5/annotations/declare/atfield/WrongTarget.aj b/tests/java5/annotations/declare/atfield/WrongTarget.aj
new file mode 100644 (file)
index 0000000..f82eae4
--- /dev/null
@@ -0,0 +1,19 @@
+// trying to put wrong annotations onto a field
+import java.lang.annotation.*;
+
+@Retention(RetentionPolicy.RUNTIME) @Target(ElementType.METHOD) @interface MethodColoring { String value(); }
+@Retention(RetentionPolicy.RUNTIME) @Target(ElementType.TYPE)   @interface TypeColoring   { String value(); }
+
+public aspect WrongTarget {
+  declare @field: public int * : @MethodColoring("red");
+  declare @field: public int * : @TypeColoring("blue");
+}
+
+aspect X {
+  before(): set(@MethodColoring * *) {
+    System.err.println("Colored field access at "+thisJoinPoint);
+  }
+  before(): set(@TypeColoring * *) {
+    System.err.println("Colored field access at "+thisJoinPoint);
+  }
+}
diff --git a/tests/java5/annotations/declare/atfield/ignoreTypeNotExposed.properties b/tests/java5/annotations/declare/atfield/ignoreTypeNotExposed.properties
new file mode 100644 (file)
index 0000000..a0b22a3
--- /dev/null
@@ -0,0 +1,2 @@
+typeNotExposedToWeaver=ignore
+adviceDidNotMatch=ignore
diff --git a/tests/java5/annotations/declare/atmethodctor/AtCtor1.aj b/tests/java5/annotations/declare/atmethodctor/AtCtor1.aj
new file mode 100644 (file)
index 0000000..f3d6903
--- /dev/null
@@ -0,0 +1,10 @@
+
+public aspect AtCtor1 {
+  declare @constructor: new(int) : @Colored("red");
+}
+
+aspect X {
+  before(): call(new(..)) && @annotation(Colored) {
+    System.err.println("Colored constructor invocation at "+thisJoinPoint);
+  }
+}
diff --git a/tests/java5/annotations/declare/atmethodctor/AtMethod1.aj b/tests/java5/annotations/declare/atmethodctor/AtMethod1.aj
new file mode 100644 (file)
index 0000000..3b9eae1
--- /dev/null
@@ -0,0 +1,11 @@
+
+public aspect AtMethod1 {
+  declare @method: void m1(..) : @Colored("red");
+
+}
+
+aspect X {
+  before(Colored c): call(* *(..)) && @annotation(c) {
+    System.err.println("Colored method invocation at "+thisJoinPoint);
+  }
+}
diff --git a/tests/java5/annotations/declare/atmethodctor/Base.class b/tests/java5/annotations/declare/atmethodctor/Base.class
new file mode 100644 (file)
index 0000000..045cae2
Binary files /dev/null and b/tests/java5/annotations/declare/atmethodctor/Base.class differ
diff --git a/tests/java5/annotations/declare/atmethodctor/Base.java b/tests/java5/annotations/declare/atmethodctor/Base.java
new file mode 100644 (file)
index 0000000..e6c8390
--- /dev/null
@@ -0,0 +1,24 @@
+import java.util.*;
+
+public class Base {
+
+  public        void m1() { System.err.println("m1() running");}
+  protected     void m2() { System.err.println("m2() running");}
+  public static void m3() { System.err.println("m3() running");}
+
+  public static void main(String[]argv) {
+ //   new Base().x();
+    new Base(3).x();
+  }
+
+  public void x() {
+    m1();
+    m2();
+    m3();
+  }
+
+  public Base() {}
+
+  public Base(int i) {}
+
+}
diff --git a/tests/java5/annotations/declare/atmethodctor/Colored.class b/tests/java5/annotations/declare/atmethodctor/Colored.class
new file mode 100644 (file)
index 0000000..df3572b
Binary files /dev/null and b/tests/java5/annotations/declare/atmethodctor/Colored.class differ
diff --git a/tests/java5/annotations/declare/atmethodctor/Colored.java b/tests/java5/annotations/declare/atmethodctor/Colored.java
new file mode 100644 (file)
index 0000000..01feb0c
--- /dev/null
@@ -0,0 +1,2 @@
+import java.lang.annotation.*; 
+@Retention(RetentionPolicy.RUNTIME) public @interface Colored {String value();}
diff --git a/tests/java5/annotations/declare/atmethodctor/Fruit.java b/tests/java5/annotations/declare/atmethodctor/Fruit.java
new file mode 100644 (file)
index 0000000..78d60bb
--- /dev/null
@@ -0,0 +1,2 @@
+import java.lang.annotation.*; 
+@Retention(RetentionPolicy.RUNTIME) public @interface Fruit {String value();}
diff --git a/tests/java5/annotations/declare/atmethodctor/RightTarget.aj b/tests/java5/annotations/declare/atmethodctor/RightTarget.aj
new file mode 100644 (file)
index 0000000..4ed1ec7
--- /dev/null
@@ -0,0 +1,19 @@
+// trying to put annotations on that correctly use @Target
+import java.lang.annotation.*;
+
+@Retention(RetentionPolicy.RUNTIME) @Target(ElementType.METHOD) @interface MethodColoring { String value(); }
+@Retention(RetentionPolicy.RUNTIME) @Target(ElementType.CONSTRUCTOR) @interface CtorColoring { String value(); }
+
+public aspect RightTarget {
+  declare @method: public void m1(..) : @MethodColoring("red");
+  declare @constructor: public new(int) : @CtorColoring("red");
+}
+
+aspect X {
+  before(): call(* *(..)) && @annotation(MethodColoring) {
+    System.err.println("Colored method call at "+thisJoinPoint);
+  }
+  before(): call(new(..)) && @annotation(CtorColoring) {
+    System.err.println("Colored ctor call at "+thisJoinPoint);
+  }
+}
diff --git a/tests/java5/annotations/declare/atmethodctor/TwoOnOneMember.aj b/tests/java5/annotations/declare/atmethodctor/TwoOnOneMember.aj
new file mode 100644 (file)
index 0000000..abc2f0c
--- /dev/null
@@ -0,0 +1,8 @@
+// trying to put two annotations onto one method and two on one ctor - should both be errors
+public aspect TwoOnOneMember {
+  declare @method: public void m1() : @Colored("red");
+  declare @method: public void m1() : @Colored("blue");
+  declare @constructor: new(int) : @Colored("red");
+  declare @constructor: new(int) : @Colored("blue");
+}
+
diff --git a/tests/java5/annotations/declare/atmethodctor/TwoOnOneMember2.aj b/tests/java5/annotations/declare/atmethodctor/TwoOnOneMember2.aj
new file mode 100644 (file)
index 0000000..633caa0
--- /dev/null
@@ -0,0 +1,23 @@
+// trying to put two annotations onto one a method and two on a ctor
+// - should be OK, they are diff annotations
+public aspect TwoOnOneMember2 {
+  declare @method: public void m1() : @Colored("red");
+  declare @method: public void m1() : @Fruit("tomato");
+  declare @constructor: new(int) : @Colored("green");
+  declare @constructor: new(int) : @Fruit("apple");
+}
+
+aspect X {
+  before(): call(* *(..)) && @annotation(Colored) {
+    System.err.println("Colored method call at "+thisJoinPoint.getSourceLocation());
+  }
+  before(): call(* *(..)) && @annotation(Fruit) {
+    System.err.println("Fruit method call at "+thisJoinPoint.getSourceLocation());
+  }
+  before(): call(new(..)) && @annotation(Colored) {
+    System.err.println("Colored ctor call at "+thisJoinPoint.getSourceLocation());
+  }
+  before(): call(new(..)) && @annotation(Fruit) {
+    System.err.println("Fruit ctor call at "+thisJoinPoint.getSourceLocation());
+  }
+}
diff --git a/tests/java5/annotations/declare/atmethodctor/WrongTarget.aj b/tests/java5/annotations/declare/atmethodctor/WrongTarget.aj
new file mode 100644 (file)
index 0000000..364ce30
--- /dev/null
@@ -0,0 +1,13 @@
+// trying to put wrong annotations onto a field
+import java.lang.annotation.*;
+
+@Retention(RetentionPolicy.RUNTIME) @Target(ElementType.FIELD) @interface MethodColoring { String value(); }
+@Retention(RetentionPolicy.RUNTIME) @Target(ElementType.TYPE)   @interface TypeColoring   { String value(); }
+
+public aspect WrongTarget {
+  declare @method: void m1(..) : @MethodColoring("red");
+  declare @method: void m1(..) : @TypeColoring("blue");
+  declare @constructor: new(..) : @MethodColoring("red");
+  declare @constructor: new(..) : @TypeColoring("blue");
+}
+
diff --git a/tests/java5/annotations/declare/atmethodctor/ignoreTypeNotExposed.properties b/tests/java5/annotations/declare/atmethodctor/ignoreTypeNotExposed.properties
new file mode 100644 (file)
index 0000000..a0b22a3
--- /dev/null
@@ -0,0 +1,2 @@
+typeNotExposedToWeaver=ignore
+adviceDidNotMatch=ignore
diff --git a/tests/java5/annotations/declare/ignoreTypeNotExposed.properties b/tests/java5/annotations/declare/ignoreTypeNotExposed.properties
new file mode 100644 (file)
index 0000000..a0b22a3
--- /dev/null
@@ -0,0 +1,2 @@
+typeNotExposedToWeaver=ignore
+adviceDidNotMatch=ignore