blob: 413bcbd94062fe2ba5d14c3592648fa2fdf4b754 (
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
|
import org.aspectj.testing.Tester;
/** From PR #496 from Mark Skipper
*/
public class NotThis {
public static void main(String[] args){
new NotThis().go();
}
void go(){
A a = new A(this);
a.go();
Tester.checkEqual(Q.buf.toString(), "foo:within(A):this(A):!within(B):!this(B):");
Q.buf = new StringBuffer();
B b = new B(this);
b.go();
Tester.checkEqual(Q.buf.toString(), "foo:");
}
public void foo(Object o){
Q.buf.append("foo:");
}
}
class A {
NotThis t;
A(NotThis n){ t = n; }
void go(){ t.foo(this); }
}
class B{
NotThis t;
B(NotThis n){ t = n; }
void go(){ t.foo(this); }
}
aspect Q {
static StringBuffer buf = new StringBuffer();
after(): call(void NotThis.foo(Object)) && within(A) {
buf.append("within(A):");
}
after(): call(void NotThis.foo(Object)) && this(A) {
buf.append("this(A):");
}
after(): call(void NotThis.foo(Object)) && !within(B) {
buf.append("!within(B):");
}
after(): call(void NotThis.foo(Object)) && !this(B) {
buf.append("!this(B):");
}
}
|