blob: 385ea70c887ee6a4f9c5a7fc8bfef9be1ee37d47 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
|
import java.lang.annotation.*;
@Retention(RetentionPolicy.RUNTIME)
@interface Colored {String value();}
public class StaticMethods {
public static void main(String[] argv) {
m1();
m2();
}
@Colored("red") static void m1() {System.err.println("m1 running");}
@Colored("blue") static void m2() {System.err.println("m2 running");}
static aspect X {
before(Colored c): call(* m*(..)) && @annotation(c) {
System.err.println("Color at "+thisJoinPoint+" is "+c.value());
}
before(Colored c): execution(* m*(..)) && @annotation(c) {
System.err.println("Color at "+thisJoinPoint+" is "+c.value());
}
}
}
|