blob: 08ef3ca041e877036860eaefeb66d2a558d68f3a (
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 org.aspectj.lang.*;
public aspect PerCflow percflow(execution(* m(..))) {
before(): execution(* Foo.*(..)) {}
public static void main(String []argv) {
print("before");
new Foo().m();
print("after");
}
public static void print(String prefix) {
System.err.println(prefix);
boolean b1 = Aspects14.hasAspect(PerCflow.class);
boolean b2 = PerCflow.hasAspect();
Object o1 = (b1?Aspects14.aspectOf(PerCflow.class):null);
Object o2 = (b2?PerCflow.aspectOf():null);
System.err.println("hasAspect? "+b1+" : "+b2);
System.err.println("aspectOf? "+o1+" : "+o2);
}
public String toString() { return "PerCflowInstance"; }
}
class Foo {
public void m() { PerCflow.print("during");}
}
|