diff options
Diffstat (limited to 'tests/java5/annotations/binding/AtTarget1.aj')
-rw-r--r-- | tests/java5/annotations/binding/AtTarget1.aj | 34 |
1 files changed, 34 insertions, 0 deletions
diff --git a/tests/java5/annotations/binding/AtTarget1.aj b/tests/java5/annotations/binding/AtTarget1.aj new file mode 100644 index 000000000..9e7f3c3ac --- /dev/null +++ b/tests/java5/annotations/binding/AtTarget1.aj @@ -0,0 +1,34 @@ +import java.lang.annotation.*;
+
+@Retention(RetentionPolicy.RUNTIME)
+@interface Colored { String color(); }
+
+@Colored(color="yellow")
+public class AtTarget1 {
+ public static void main(String[]argv) {
+ new AtTarget1().m();
+ }
+
+ @Colored(color="red")
+ public void m() {
+ System.err.println("method");
+ }
+
+}
+
+aspect X {
+ int adviceExecutions = 0;
+
+ before(Colored c): call(* *(..)) && !within(X) && @target(c) {
+ System.err.println(c.color());
+ adviceExecutions++;
+
+ if (!c.color().equals("yellow"))
+ throw new RuntimeException("Color should be yellow");
+
+ if (adviceExecutions>1)
+ throw new RuntimeException("Advice shouldn't be called more than once");
+ }
+
+}
+
|