blob: 64f5ec4505af5fc8900e3170f813213737109fc1 (
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
|
import org.aspectj.testing.Tester;
import org.aspectj.testing.Tester;
public class BackdoorMethods {
public static void main(String[] args) {
new BackdoorMethods().realMain(args);
}
public void realMain(String[] args) {
new _A().a();
new _B().a();
new _C().a();
new _D().a();
Tester.checkAllEvents();
}
static {
for (char c = 'A'; c <= 'D'; c++) {
String n = "_"+c+".";
Tester.expectEvent(n+"a");
if (c != 'D') Tester.expectEvent(n+"f");
Tester.expectEvent(n+"g");
Tester.expectEvent("before."+n+"a");
if (c != 'D') Tester.expectEvent("before."+n+"g");
}
}
}
class O {
public void a() { Tester.event(n("a")); }
protected String n() { return getClass().getName() + "."; }
protected String n(Object s) { return n() + s; }
}
class A extends O { public void f() { Tester.event(n("f")); } }
class B extends O { void f() { Tester.event(n("f")); } }
class C extends O { protected void f() { Tester.event(n("f")); } }
class D extends O { private void f() { Tester.event(n("f")); } }
class _A extends O { public void g() { Tester.event(n("g")); } }
class _B extends O { void g() { Tester.event(n("g")); } }
class _C extends O { protected void g() { Tester.event(n("g")); } }
class _D extends O { private void g() { Tester.event(n("g")); } }
privileged aspect Aspect {
declare parents: _A extends A;
declare parents: _B extends B;
declare parents: _C extends C;
declare parents: _D extends D;
before(_A o): target(o) && call(void g()) { o.f(); n(o,"g"); }
before(_B o): target(o) && call(void g()) { o.f(); n(o,"g"); }
before(_C o): target(o) && call(void g()) { o.f(); n(o,"g"); }
before(_A o): target(o) && call(void a()) { o.g(); n(o,"a"); }
before(_B o): target(o) && call(void a()) { o.g(); n(o,"a"); }
before(_C o): target(o) && call(void a()) { o.g(); n(o,"a"); }
before(_D o): target(o) && call(void a()) { o.g(); n(o,"a"); }
private static void n(Object o, String m) {
Tester.event("before." + o.getClass().getName() + "." + m);
}
}
|