blob: e6051799ae2c2defd8a4a95329e1779b08610f35 (
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
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
|
package pcds;
import org.aspectj.testing.Tester;
public class Simple {
public static void main(String[] args) {
C c = new C();
c.m("hi");
C subc = new SubC();
subc.m("hi");
subc.m(new Integer(1));
SubC subc1 = new SubC();
subc1.m("bye");
subc.hashCode();
}
}
class C {
void m(Object o) {
System.out.println("C.m(" + o + ")");
}
static pointcut meths(C c): call(void m(Object)) && target(c);
}
class SubC extends C {
SubC(int x) {
System.out.println("x: " + x);
}
SubC(String s) {
this(2*2);
System.out.println("s: " + s);
int x = 10;
}
SubC() {
this("hi");
System.out.println("no args");
}
}
aspect A {
before(Object o): C.meths(o) {
System.out.println("static named pointcut");
}
before(): call(void m(..)) && target(SubC) && args(String) {
System.out.println("dmatches: " + thisJoinPoint);
}
before(): call(void SubC.m(String)) {
System.out.println("!smatches: " + thisJoinPoint);
}
before(Object o, String s): call(void C.m(Object)) && target(SubC) && args(s) && args(o) {
System.out.println("smatches: " + thisJoinPoint +", " + s +", " + o);
}
before(): initialization(SubC.new(..)) {
System.out.println(thisJoinPoint + "new SubC");
}
void around(): initialization(SubC.new(..)) {
proceed();
}
before(): execution(SubC.new(..)) {
System.out.println(thisJoinPoint + "new SubC");
}
before(): call(int Object.hashCode()) {
System.out.println("hashCode()");
}
before(): call(int Object.hashCode()) && target(C) {
System.out.println("hashCode() on C");
}
}
|