blob: a4bedb983837015ea2ad9c591f9087354b004d84 (
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
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
|
import org.aspectj.testing.Tester;
public class CallsTo {
public static void main(String[] args) {
Tester.clearNotes();
//System.out.println("cleared events");
//Tester.printEvents();
C c = new C();
Tester.checkAndClear
("ca-newC",
"new C");
c.m("a");
Tester.checkAndClear
("re-all re-C ca-all ca-C ",
"c.m");
c.m_C("b");
Tester.checkAndClear
("re-all re-C ca-all ca-C ",
"c.m_C");
c = new SubC();
Tester.checkAndClear
("ca-newC",
"new SubC");
c.m("c");
Tester.checkAndClear
("re-all re-C re-SubC ca-all ca-C ca-SubC ca-inst(SubC)",
"subc.m");
c.m_C("d");
Tester.checkAndClear
("re-all re-C re-SubC ca-all ca-C ca-SubC ca-inst(SubC)",
"subc.m_C");
SubC subC = new SubC();
Tester.checkAndClear
("ca-newC",
"new SubC");
subC.m("e");
Tester.checkAndClear
("re-all re-C re-SubC ca-all ca-C ca-SubC ca-inst(SubC)",
"subc.m");
subC.m_C("f");
Tester.checkAndClear
("re-all re-C re-SubC ca-all ca-C ca-SubC ca-inst(SubC)",
"subc.m_C");
subC.m_SubC();
Tester.checkAndClear
("re-all re-SubC ca-all ca-SubC",
"subc.m_SubC");
}
}
class C {
public void m(String s1) {}
public void m_C(String s2) {}
}
class SubC extends C {
public void m(String s3) {}
public void m_SubC() {}
}
aspect A {
// pointcut allReceptions(): receptions(void *(..)) && instanceof(C);
// pointcut receptionsInC(String s): receptions(void C.*(s));
// pointcut receptionsInSubC(): receptions(void SubC.*(..));
pointcut allcall(): call(void *(..)) && target(C+);
pointcut callInC(String s): call(void C+.*(String)) && args(s);
pointcut callInSubC(): call(void *(..)) && target(SubC);
before(): allcall() { note("re-all"); }
before(String s): callInC(s) { note("re-C"); }
before(): callInSubC() { note("re-SubC"); }
before(): allcall() { note("ca-all"); }
before(String s): callInC(s) { note("ca-C"); }
before(): callInSubC() { note("ca-SubC"); }
before(): call(void C.*(..)) && target(SubC) { note("ca-inst(SubC)"); }
// not implemented
// before(OnSubC o): call(void C.*(..)) && (hasaspect(OnSubC) && target(o)) {
// note("ca-asp(SubC)");
// }
before(): call(C+.new(..)) { note("ca-newC"); }
private final static void note(String msg) {
Tester.note(msg);
}
}
aspect OnSubC /**of eachobject(instanceof(SubC))*/ {
}
|