blob: bcf5199d2d6f546d1a437c13a946babc3b2555cb (
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
|
import org.aspectj.testing.*;
/** @testcase PR#661 !target with second advice on casted call */
public class CallNotTarget {
public static void main (String args []) {
//new B().go(); // remove cast to avoid bug
((I) new B()).go();
Tester.checkAllEvents();
doit(new B());
doit(new A());
}
static {
Tester.expectEvent("A.before");
Tester.expectEvent("A.before-not");
Tester.expectEvent("Aspect.before-not");
Tester.expectEvent("go");
}
static void doit(I i) {
Tester.check(i != null, "null i");
//System.out.println(i);
}
}
interface I { public void go (); }
class A implements I {
public void go () { Tester.check(false, "A"); }
}
class B implements I {
public void go () { Tester.event("go"); }
}
aspect Aspect {
pointcut pc() : call(void I.go()); // same result if pointcut not named
before () : pc() { // remove this advice to avoid bug
Tester.event("A.before");
}
before () : pc() && !target (A) { // change to !target(String) to avoid bug
Tester.event("A.before-not");
}
before () : pc() && !target (Aspect) { // change to !target(String) to avoid bug
Tester.event("Aspect.before-not");
}
// before(): call(void doit(I)) && !args(A) {
// System.out.println("doit !A");
// }
}
|