blob: 1922506e7596ae9d9f1bd77b90c939a28d86f859 (
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
|
import org.aspectj.testing.Tester;
public class Fixes {
public static void main(String[] args) { new Fixes().realMain(args); }
public void realMain(String[] args) {
new TheObject().go();
}
}
class TheObject {
private int private_int;
void go () {}
}
privileged aspect TheAspect pertarget(target(TheObject)) {
private TheObject theObject;
after() returning(TheObject obj): call(new()) {
theObject = obj;
}
after() returning(): call(* realMain(..)) {
start();
postinc();
preinc();
postdec();
predec();
}
void start() {
theObject.private_int = 3;
}
void postinc() {
enter("postinc");
a(theObject.private_int,3);
theObject.private_int++;
a(theObject.private_int,4);
}
void preinc() {
enter("preinc");
a(theObject.private_int,4);
++theObject.private_int;
a(theObject.private_int,5);
}
void postdec() {
enter("postdec");
a(theObject.private_int,5);
theObject.private_int--;
a(theObject.private_int,4);
}
void predec() {
enter("predec");
a(theObject.private_int,4);
--theObject.private_int;
a(theObject.private_int,3);
}
private String msg;
void enter(String msg) {
this.msg = msg;
}
void a(int a, int b) {
Tester.checkEqual(a,b,msg);
}
}
|