12345678910111213141516171819202122232425262728 |
- import java.lang.annotation.*;
-
- @Retention(RetentionPolicy.RUNTIME) @interface Colored { String color(); }
- @Retention(RetentionPolicy.RUNTIME) @interface Fruit { String value(); }
-
- @Colored(color="yellow") @Fruit("banana") class YB {}
-
- public class AtArgs3 {
- public static void main(String[]argv) {
- m(new YB());
- if (!X.b)
- throw new Error("Advice should have run");
- }
-
- public static void m(Object a) {}
-
- }
-
- aspect X {
-
- static boolean b = false;
-
- before(): call(* m(..)) && !within(X) && @args(Colored) {
- b=true;
- }
-
- }
-
|