blob: a06fe518c8b196415b7f62a09c8904b96c724c3d (
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
29
30
31
32
33
34
35
36
37
38
39
40
41
42
|
import java.io.PrintStream;
import java.lang.annotation.*;
@Retention(RetentionPolicy.RUNTIME) @interface Marker {}
class A {
@Marker void foo() { }
public static void main(String[] args) {
new A().foo();
}
}
public class CflowOrder {
public static void main(String[] args) {
A.main(null);
}
static aspect MyAspect {
pointcut annotated(Marker a) : execution(@Marker * *(..)) && @annotation(a);
pointcut belowAnnotated() : cflowbelow(annotated(Marker));
// pointcut belowAnnotated() : cflowbelow(execution(@Marker * *(..)) && @annotation(Marker));
pointcut topAnnotated(Marker a) : annotated(a) && !belowAnnotated();
pointcut notTopAnnotated(/*Marker a,*/ Marker aTop) :
/* annotated(a) &&*/ cflowbelow(annotated(aTop));
// if this first, then no nonTopAnnotated advice
before(Marker a) : topAnnotated(a) { }
// if topAnnotated is first, this does not run
before(Marker aTop) : notTopAnnotated( aTop) { }
}
}
|