aboutsummaryrefslogtreecommitdiffstats
path: root/tests/pureJava/LocalsFromInnerCP.java
blob: d135d3458b6d444a83797ccf72a633fff1f001f1 (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
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
import org.aspectj.testing.*;

/** @testcase PUREJAVA PR#739 final local variables can be accessed from inner class */
public class LocalsFromInnerCP {
    public static void main (String[] args) {
        // static init
        LocalsFromInnerCP.registerAll();
        LocalsFromInnerCP me = new LocalsFromInnerCP();
        me = new LocalsFromInnerCP(1);
        me.f();
        LocalsFromInnerCP.sf();
        me.f(1);
        LocalsFromInnerCP.sf(1);
        me.m();
        me.m(1);
        me.new m().f();
        me.new m().f(1);
        Tester.check(globali == 11, "globali: " + globali);
        Tester.checkAllEvents();
    } 
    
    void f() {
        final int i = 1;
        new Runnable() {
                public void run() { signal("LocalsFromInnerCP.f().Runnable.run()", i); } 
            }.run();
    }

    static void sf() {
        final int i = 1;
        new Runnable() {
                public void run() { signal("LocalsFromInnerCP.sf().Runnable.run()", i); } 
            }.run();
    }

    void f(final int i) {
        new Runnable() {
                public void run() { signal("LocalsFromInnerCP.f(int).Runnable.run()", i); } 
            }.run();
    }

    static void sf(final int i) {
        new Runnable() {
                public void run() { signal("LocalsFromInnerCP.sf(int).Runnable.run()", i); } 
            }.run();
    }

    static {
        final int i = 1;
        new Runnable() {
                public void run() { signal("LocalsFromInnerCP.<clinit>.Runnable.run()", i); } 
            }.run();
    }

    void m(final int i) {
        class m {
            void f() {
                new Runnable() {
                        public void run() { signal("LocalsFromInnerCP.m(int).m.f().Runnable.run()", i); } 
                    }.run();
            }
        }
        new m().f();
    }

    void m() {
        final int i = 1;
        class m {
            void f() {
                new Runnable() {
                        public void run() { signal("LocalsFromInnerCP.m().m.f().Runnable.run()", i); } 
                    }.run();
            }
        }
        new m().f();
    }

    class m {
        void f() {
            final int i = 1;
            new Runnable() {
                    public void run() { signal("LocalsFromInnerCP.m.f().Runnable.run()", i); } 
                }.run();
        }
 
        void f(final int i) {
            new Runnable() {
                    public void run() { signal("LocalsFromInnerCP.m.f(int).Runnable.run()", i); } 
                }.run();
        }
    }

    LocalsFromInnerCP() {
        final int i = 1;
        new Runnable() {
                public void run() { signal("LocalsFromInnerCP.LocalsFromInnerCP().Runnable.run()", i); } 
            }.run();
    }

    LocalsFromInnerCP(final int i) {
        new Runnable() {
                public void run() { signal("LocalsFromInnerCP.LocalsFromInnerCP(int).Runnable.run()", i); } 
            }.run();
    }
    //----------------------------------------------------------
    // sed -n '/"/p' pureJava/LocalsFromInnerCP.java 
    //   | sed 's|.*"\(.*\)".*|    register("\1");|' 
    // >> pureJava/LocalsFromInnerCP.java
    static void registerAll() {
        register("LocalsFromInnerCP.f().Runnable.run()");
        register("LocalsFromInnerCP.sf().Runnable.run()");
        register("LocalsFromInnerCP.f(int).Runnable.run()");
        register("LocalsFromInnerCP.sf(int).Runnable.run()");
        register("LocalsFromInnerCP.<clinit>.Runnable.run()");
        register("LocalsFromInnerCP.m(int).m.f().Runnable.run()");
        register("LocalsFromInnerCP.m().m.f().Runnable.run()");
        register("LocalsFromInnerCP.m.f().Runnable.run()");
        register("LocalsFromInnerCP.m.f(int).Runnable.run()");
        register("LocalsFromInnerCP.LocalsFromInnerCP().Runnable.run()");
        register("LocalsFromInnerCP.LocalsFromInnerCP(int).Runnable.run()");
    }
    static void register(String s) {
        Tester.expectEvent(s);
    }
    static int globali;
    static void signal(String s, int i) {
        Tester.event(s);
        Tester.check(i == 1, "1 != i=" + i + " for " + s);
        globali++;
    }
}