blob: 4af57af24619baa58946206af6ca22360cc309bd (
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
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
|
import org.aspectj.lang.annotation.Aspect;
import org.aspectj.lang.annotation.Before;
import org.aspectj.lang.annotation.Pointcut;
/**
* This test is exploring situations where an if() pointcut is used with a parameter
* and yet a reference pointcut referring to it is not binding the parameter.
*/
public class C {
int i;
C(int i) {
this.i = i;
}
public static void main(String []argv) {
new C(1).run();
}
public void run() {
System.out.println("C.run() executing");
}
public String toString() {
return "C("+i+")";
}
}
@Aspect
abstract class Azpect1 {
@Pointcut("if(false)")
public void isCondition() {}
@Before("isCondition() && execution(* C.run(..))")
public void beforeAdvice() {
System.out.println("Azpect1.beforeAdvice executing");
}
}
@Aspect
class Azpect2 extends Azpect1 {
@Pointcut("check(*)")
public void isCondition() { }
@Pointcut("this(c) && if()")
public static boolean check(C c) {
System.out.println("check if() pointcut running on "+c.toString());
return true;
}
}
//
//abstract aspect A {
// pointcut isCondition(): if(false);
// before(): isCondition() && execution(* C.run(..)) { System.out.println("A.before"); }
//}
//
//aspect B extends A {
// pointcut isCondition(): check(*);
// pointcut check(Object o): this(o) && if(o.toString().equals("abc"));
//}
|