AnonymousInSuperCallNegTest.java revision 3655:535f80a0a2fd
1/*
2 * @test /nodynamiccopyright/
3 * @bug 8166108
4 * @summary Verify that a program cannot access instance state before construction
5 * @compile/fail/ref=AnonymousInSuperCallNegTest.out -XDrawDiagnostics AnonymousInSuperCallNegTest.java
6 */
7
8public class AnonymousInSuperCallNegTest {
9
10    static class Base {
11        Base(Object o) {}
12    }
13
14    static class Outer {
15        class Inner {}
16    }
17
18    public static class JavacBug extends Base {
19        int x;
20        JavacBug() {
21            super(new Outer().new Inner() {
22                void foo() {
23                    System.out.println("x = " + x);
24                }
25            }); }
26    }
27
28    public static void main(String[] args) {
29        new JavacBug();
30    }
31}