diff options
author | aclement <aclement> | 2005-01-31 11:32:01 +0000 |
---|---|---|
committer | aclement <aclement> | 2005-01-31 11:32:01 +0000 |
commit | 110b3d31ac12ea19c73963577fdfe18c69e5f4db (patch) | |
tree | 189df97e701774865b739127f70f220a2ea25e05 /tests/java5/annotations/binding/CallAnnBinding4.aj | |
parent | 4501853bf4c480479a517a714805291d04febb98 (diff) | |
download | aspectj-110b3d31ac12ea19c73963577fdfe18c69e5f4db.tar.gz aspectj-110b3d31ac12ea19c73963577fdfe18c69e5f4db.zip |
AnnotationBinding testcases: call and execution. Also verifies annotations in packages work correctly.
Diffstat (limited to 'tests/java5/annotations/binding/CallAnnBinding4.aj')
-rw-r--r-- | tests/java5/annotations/binding/CallAnnBinding4.aj | 44 |
1 files changed, 44 insertions, 0 deletions
diff --git a/tests/java5/annotations/binding/CallAnnBinding4.aj b/tests/java5/annotations/binding/CallAnnBinding4.aj new file mode 100644 index 000000000..1cd1d31fc --- /dev/null +++ b/tests/java5/annotations/binding/CallAnnBinding4.aj @@ -0,0 +1,44 @@ +import java.lang.annotation.*;
+
+@Retention(RetentionPolicy.RUNTIME)
+@interface Colored { String color(); }
+
+interface Marker { @Colored(color="blue") public void m1(); public void m2(); }
+
+public class CallAnnBinding4 {
+ public static void main(String[]argv) {
+ Marker marker = new SecondaryClass();
+
+ // tackle the primitives ...
+
+ marker.m1();
+ marker.m2();
+
+ if (X.i!=1) throw new RuntimeException("Why did the advice not run once?");
+ }
+
+}
+
+class SecondaryClass implements Marker {
+
+ @Colored(color="red") public void m1() {}
+ @Colored(color="orange") public void m2() {}
+}
+
+aspect X {
+ public static int i = 0;
+
+ before(Colored c): call(* m*(..)) && !within(X) && @annotation(c) {
+ i++;
+ if (i==1) checkColor(1,c,"blue");
+
+ if (i==2) throw new RuntimeException("Advice running more times than expected");
+ System.err.println(c.color());
+ }
+
+ public void checkColor(int run, Colored c,String exp) {
+ if (!c.color().equals(exp))
+ throw new RuntimeException("Advice execution #"+run+" expected "+exp+" but got "+c.color());
+ }
+}
+
|