blob: 391e7c82dfda15e2fb2bc1727a0d33b8de8d114c (
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
|
import org.aspectj.testing.Tester;
import org.aspectj.testing.Tester;
public class IntroducedFieldsNotBinding {
public static void main(String[]args) {
TargetClass target = new TargetClass();
// when the compiler passes the test, validate runtime
int result = target.getField();
Tester.checkEqual(result, 1, "1 != result: " + result);
Tester.checkAllEvents();
}
static {
Tester.event("execution of getField");
}
}
class TargetClass { }
class TargetClass2 { }
aspect A {
private String TargetClass2.s = "hi";
private int TargetClass.field = 1;
public int TargetClass.getField() {
int i = field; // compiler error here
String s = new TargetClass2().s;
Tester.checkEqual(s, "hi");
Runnable r = new Runnable() {
public void run() {
System.out.println("running: " + field);
}
};
r.run();
return i ;
}
after ()
: execution(public int TargetClass.getField()) {
Tester.expectEvent("execution of getField");
}
}
|