aboutsummaryrefslogtreecommitdiffstats
path: root/tests/java5/annotations/binding
diff options
context:
space:
mode:
authoraclement <aclement>2005-03-17 19:56:13 +0000
committeraclement <aclement>2005-03-17 19:56:13 +0000
commit8e275e3b934fd973ca04e358e994e50e9668b415 (patch)
treef4f13d03cf67b45c22701f8bd6304d1f817e5273 /tests/java5/annotations/binding
parentf82e6f25e306cefb9278e46df2abd3765582ff36 (diff)
downloadaspectj-8e275e3b934fd973ca04e358e994e50e9668b415.tar.gz
aspectj-8e275e3b934fd973ca04e358e994e50e9668b415.zip
Declare annotation with ITDs: testcode
Diffstat (limited to 'tests/java5/annotations/binding')
-rw-r--r--tests/java5/annotations/binding/BindingWithAnnotatedItds1.aj26
-rw-r--r--tests/java5/annotations/binding/BindingWithAnnotatedItds2.aj37
-rw-r--r--tests/java5/annotations/binding/BindingWithAnnotatedItds3.aj33
-rw-r--r--tests/java5/annotations/binding/BindingWithDeclaredAnnotationItds1.aj44
-rw-r--r--tests/java5/annotations/binding/BindingWithDeclaredAnnotationItds2.aj39
-rw-r--r--tests/java5/annotations/binding/BindingWithDeclaredAnnotationItds3.aj36
-rw-r--r--tests/java5/annotations/binding/BindingWithDeclaredAnnotationItds4.aj37
7 files changed, 252 insertions, 0 deletions
diff --git a/tests/java5/annotations/binding/BindingWithAnnotatedItds1.aj b/tests/java5/annotations/binding/BindingWithAnnotatedItds1.aj
new file mode 100644
index 000000000..0c2ac3079
--- /dev/null
+++ b/tests/java5/annotations/binding/BindingWithAnnotatedItds1.aj
@@ -0,0 +1,26 @@
+// Annotated ITD (method) being matched upon and extracted
+import java.lang.annotation.*;
+
+@Retention(RetentionPolicy.RUNTIME) @interface Fruit { String value();}
+
+public aspect BindingWithAnnotatedItds1 {
+
+ @Fruit("apple") int A.m() { return 1; }
+
+ public static void main(String[]argv) {
+ A a = new A();
+ a.m();
+ }
+
+}
+
+class A { }
+
+aspect X {
+
+ before(Fruit f): execution(* *(..)) && @annotation(f) {
+ System.err.println("Found "+f.value()+" at jp "+thisJoinPoint+
+ " ("+thisJoinPoint.getSourceLocation()+")");
+ }
+
+}
diff --git a/tests/java5/annotations/binding/BindingWithAnnotatedItds2.aj b/tests/java5/annotations/binding/BindingWithAnnotatedItds2.aj
new file mode 100644
index 000000000..f7cee7baa
--- /dev/null
+++ b/tests/java5/annotations/binding/BindingWithAnnotatedItds2.aj
@@ -0,0 +1,37 @@
+// Annotated ITD (field) being matched upon and extracted
+import java.lang.annotation.*;
+
+@Retention(RetentionPolicy.RUNTIME) @interface Fruit { String value();}
+
+public aspect BindingWithAnnotatedItds2 {
+
+ @Fruit("banana") int A.i;
+
+ public @Fruit("apple") String A.j;
+
+ private @Fruit("orange") int[] A.k;
+
+ public static void main(String[]argv) {
+ A a = new A();
+ a.i = 5;
+ a.j = "hello";
+ a.k = new int[]{1,2,3};
+ }
+
+}
+
+class A { }
+
+aspect X {
+
+ before(Fruit f): set(* *) && @annotation(f) {
+ System.err.println("Found "+f.value()+" at jp "+thisJoinPoint+
+ " ("+thisJoinPoint.getSourceLocation()+")");
+ }
+
+ //before(Fruit f): execution(* *(..)) && @annotation(f) {
+ // System.err.println("Execution of something fruity at this jp"+thisJoinPoint+
+ // " ("+thisJoinPoint.getSourceLocation()+")");
+ //}
+
+}
diff --git a/tests/java5/annotations/binding/BindingWithAnnotatedItds3.aj b/tests/java5/annotations/binding/BindingWithAnnotatedItds3.aj
new file mode 100644
index 000000000..8bee421ec
--- /dev/null
+++ b/tests/java5/annotations/binding/BindingWithAnnotatedItds3.aj
@@ -0,0 +1,33 @@
+// Annotated ITD (ctor) being matched upon and extracted
+import java.lang.annotation.*;
+
+@Retention(RetentionPolicy.RUNTIME) @interface Fruit { String value();}
+
+public aspect BindingWithAnnotatedItds3 {
+
+ @Fruit("pear") A.new(String s) { }
+
+ private @Fruit("orange") A.new(int i) { }
+
+ public @Fruit("tomato") A.new(boolean b) { }
+
+ public static void main(String[]argv) {
+ A instance1 = new A("a");
+ A instance2 = new A(3);
+ A instance3 = new A(true);
+ }
+
+}
+
+class A {
+
+}
+
+aspect X {
+
+ before(Fruit f): execution(new(..)) && @annotation(f) {
+ System.err.println("Found "+f.value()+" at jp "+thisJoinPoint+
+ " ("+thisJoinPoint.getSourceLocation()+")");
+ }
+
+}
diff --git a/tests/java5/annotations/binding/BindingWithDeclaredAnnotationItds1.aj b/tests/java5/annotations/binding/BindingWithDeclaredAnnotationItds1.aj
new file mode 100644
index 000000000..4f36edcfb
--- /dev/null
+++ b/tests/java5/annotations/binding/BindingWithDeclaredAnnotationItds1.aj
@@ -0,0 +1,44 @@
+// Annotated ITD (method) being matched upon and extracted
+import java.lang.annotation.*;
+
+@Retention(RetentionPolicy.RUNTIME) @interface Fruit { String value();}
+
+public aspect BindingWithDeclaredAnnotationItds1 {
+
+ int A.m() { return 1; }
+
+ public int A.n() { return 2; }
+
+ private int A.o() { return 3; }
+
+ public static void main(String[]argv) {
+ A a = new A();
+ a.m();
+ a.n();
+ a.o();
+ }
+
+}
+
+class A { }
+
+aspect X {
+
+ declare @method: int A.m(): @Fruit("orange");
+
+ declare @method: int A.n(): @Fruit("banana");
+
+ declare @method: int A.o(): @Fruit("tomato");
+
+ before(Fruit f): execution(* *(..)) && @annotation(f) {
+ System.err.println("Found "+f.value()+" at jp "+thisJoinPoint+
+ " ("+thisJoinPoint.getSourceLocation()+")");
+ }
+
+ before(Fruit f): call(* *(..)) && @annotation(f) {
+ System.err.println("Found "+f.value()+" at jp "+thisJoinPoint+
+ " ("+thisJoinPoint.getSourceLocation()+")");
+ }
+
+
+}
diff --git a/tests/java5/annotations/binding/BindingWithDeclaredAnnotationItds2.aj b/tests/java5/annotations/binding/BindingWithDeclaredAnnotationItds2.aj
new file mode 100644
index 000000000..3e852a959
--- /dev/null
+++ b/tests/java5/annotations/binding/BindingWithDeclaredAnnotationItds2.aj
@@ -0,0 +1,39 @@
+// Annotated ITD (field) being matched upon and extracted
+import java.lang.annotation.*;
+
+@Retention(RetentionPolicy.RUNTIME) @interface Fruit { String value();}
+
+public aspect BindingWithDeclaredAnnotationItds2 {
+
+ int A.i;
+
+ private String A.j;
+
+ public boolean[] A.k;
+
+ public static void main(String[]argv) {
+ A a = new A();
+ a.i = 5;
+ a.j = "hello";
+ a.k = new boolean[]{true,false};
+ }
+
+}
+
+class A { }
+
+aspect X {
+
+ declare @field: int A.i: @Fruit("orange");
+
+ declare @field: String A.j: @Fruit("banana");
+
+ declare @field: boolean[] A.k: @Fruit("apple");
+
+ before(Fruit f): set(* *) && @annotation(f) {
+ System.err.println("Found "+f.value()+" at jp "+thisJoinPoint+
+ " ("+thisJoinPoint.getSourceLocation()+")");
+ }
+
+
+}
diff --git a/tests/java5/annotations/binding/BindingWithDeclaredAnnotationItds3.aj b/tests/java5/annotations/binding/BindingWithDeclaredAnnotationItds3.aj
new file mode 100644
index 000000000..3dd5e0d10
--- /dev/null
+++ b/tests/java5/annotations/binding/BindingWithDeclaredAnnotationItds3.aj
@@ -0,0 +1,36 @@
+// Annotated ITD (field) being matched upon and extracted
+import java.lang.annotation.*;
+
+@Retention(RetentionPolicy.RUNTIME) @interface Fruit { String value();}
+@Retention(RetentionPolicy.RUNTIME) @interface Drink { String value();}
+
+public aspect BindingWithDeclaredAnnotationItds3 {
+
+ int A.i;
+
+ public static void main(String[]argv) {
+ A a = new A();
+ a.i = 5;
+ }
+
+}
+
+class A { }
+
+aspect X {
+
+ declare @field: int A.i: @Fruit("orange");
+ declare @field: int A.i: @Drink("margarita");
+
+ before(Fruit f): set(* *) && @annotation(f) {
+ System.err.println("Found fruit "+f.value()+" at jp "+thisJoinPoint+
+ " ("+thisJoinPoint.getSourceLocation()+")");
+ }
+
+ before(Drink d): set(* *) && @annotation(d) {
+ System.err.println("Found drink "+d.value()+" at jp "+thisJoinPoint+
+ " ("+thisJoinPoint.getSourceLocation()+")");
+ }
+
+
+}
diff --git a/tests/java5/annotations/binding/BindingWithDeclaredAnnotationItds4.aj b/tests/java5/annotations/binding/BindingWithDeclaredAnnotationItds4.aj
new file mode 100644
index 000000000..2ecc73c64
--- /dev/null
+++ b/tests/java5/annotations/binding/BindingWithDeclaredAnnotationItds4.aj
@@ -0,0 +1,37 @@
+// Annotated ITD (ctor) being matched upon and extracted
+import java.lang.annotation.*;
+
+@Retention(RetentionPolicy.RUNTIME) @interface Fruit { String value();}
+
+public aspect BindingWithDeclaredAnnotationItds4 {
+
+ A.new(String s) { }
+
+ private A.new(int i) { }
+
+ public A.new(boolean b) { }
+
+ public static void main(String[]argv) {
+ A instance1 = new A("a");
+ A instance2 = new A(3);
+ A instance3 = new A(true);
+ }
+
+}
+
+class A {
+
+}
+
+aspect X {
+
+ declare @constructor: A.new(String): @Fruit("pear");
+ declare @constructor: A.new(int): @Fruit("orange");
+ declare @constructor: A.new(boolean): @Fruit("tomato");
+
+ before(Fruit f): execution(new(..)) && @annotation(f) {
+ System.err.println("Found "+f.value()+" at jp "+thisJoinPoint+
+ " ("+thisJoinPoint.getSourceLocation()+")");
+ }
+
+}