blob: 790b8de59aecfde220f208955b1c7795778593ee (
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
|
// lifted directly from Mark's email
import org.aspectj.testing.Tester;
public class CallsReceptionsCallsto {
static final String desiredString =
"(calls) (callsto) (receptions) G.foo(A) G.foo(D) (calls) (callsto) (receptions) G.foo(A) G.foo(D) ";
static StringBuffer buffer;
public static void main(String[] args) {
buffer = new StringBuffer();
new C().go();
String foundString = buffer.toString();
Tester.checkEqual(foundString, desiredString);
}
}
class C {
A a = new A();
D d = new D();
G g = new G();
void go(){
g.foo(a);
g.foo(d);
bar(g);
bash(g);
}
void bar(I i){
i.foo(a);
}
void bash(J j){
j.foo(d);
}
}
aspect Q {
pointcut pc2(): /*calls*/ within(C) && call(void I.foo(*));
pointcut pc1(): /*receptions*/ call(void I.foo(*));
pointcut pc3(): /*callsto*/ call(* I.foo(*));
before (): pc2() {
CallsReceptionsCallsto.buffer.append("(calls) ");
}
before(): pc3(){
CallsReceptionsCallsto.buffer.append("(callsto) ");
}
before(): pc1() {
CallsReceptionsCallsto.buffer.append("(receptions) ");
}
}
class A {}
class D {}
interface I {
void foo(A a);
}
interface J {
void foo(D d);
}
class G implements I, J {
public void foo(A a){
CallsReceptionsCallsto.buffer.append("G.foo(A) ");
}
public void foo(D d){
CallsReceptionsCallsto.buffer.append("G.foo(D) ");
}
}
|