mirror of
https://github.com/eclipse-aspectj/aspectj.git
synced 2024-09-13 23:55:51 +02:00
43 lines
1.1 KiB
Java
43 lines
1.1 KiB
Java
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) { }
|
|
}
|
|
}
|
|
|