blob: 8d843e36d089ba8a96288a1892d34b903e0b8886 (
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
|
public class If {
public static void main(String[] args) {
C c = new C();
c.m(true);
c.m(false);
c.m(true);
c.m(false);
}
}
class C {
static boolean test() { return value; }
static boolean value = false;
void m(boolean b) {
value = b;
System.out.println("C.m(" + b + ")");
}
}
aspect A {
static boolean testA() { return true; }
boolean itestA() { return true; }
boolean t = true;
before(): call(void m(boolean)) && if(C.test()) {
System.out.println(thisJoinPoint);
}
before(boolean x): call(void m(boolean)) && args(x) && if(x) && if(testA()) && if(this.t) &&
if(thisJoinPoint.getSignature().getName().equals("m")) && if(itestA()) {
System.out.println(x + ": " + thisJoinPoint);
}
pointcut cut(boolean a): call(void m(boolean)) && args(a) && if(a) && if(this.itestA()) && if(t);
before(boolean x): cut(x) {
System.out.println(x);
}
before(Object t): target(t) && call(void m(boolean)) && if(t instanceof C) {
System.out.println(t);
}
before(Object t): target(t) && call(void m(boolean)) && if(t instanceof String) {
System.out.println(t);
}
before(C c): target(c) && call(void m(boolean)) && if(c.value) {
System.out.println(thisJoinPoint);
}
}
|