summaryrefslogtreecommitdiffstats
path: root/tests/new/FieldInnerAccess.java
blob: f7a0c034fac114964a610dc0c8dc73f4fe6a6531 (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
import org.aspectj.testing.Tester;

public class FieldInnerAccess {
    public static void main(String[] args) {
        Derived d = new Derived();
        d.m();
        Tester.checkAndClearEvents(new String[] {"lock: 1"});

        d.mi();
        Tester.checkAndClearEvents(new String[] {"lock: 1"});

        d.mib();
        Tester.checkAndClearEvents(new String[] {"lock: foo"});
    }
}

class Base {
    private static String lock = "foo";

    public void mib() {
        Runnable r = new Runnable() {
                public void run() {
                    Tester.event("lock: " + lock);
                }
            };

        r.run();
    }
}

class Derived extends Base {
    private static Object lock = new Integer(1);

    public void m() {
        Tester.event("lock: " + lock);
    }

    public void mi() {
        Runnable r = new Runnable() {
                public void run() {
                    Tester.event("lock: " + lock);
                }
            };

        r.run();
    }
}