langtools/test/tools/javac/implicitThis/NewBeforeOuterConstructed2.java
author katleman
Thu, 21 Aug 2014 14:16:14 -0700
changeset 25878 6d561031123e
parent 25439 26d6d07eebc7
permissions -rw-r--r--
Added tag jdk9-b27 for changeset 98ce0879ab4c
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
10
06bc494ca11e Initial load
duke
parents:
diff changeset
     1
/*
25439
26d6d07eebc7 8044080: .out files for unicode, implicitThis and importChecks tests in tools/javac dir
sogoel
parents: 5520
diff changeset
     2
 * @test /nodynamiccopyright/
10
06bc494ca11e Initial load
duke
parents:
diff changeset
     3
 * @bug 4689058
06bc494ca11e Initial load
duke
parents:
diff changeset
     4
 * @summary unverifiable code for implicit outer in super constructor call
06bc494ca11e Initial load
duke
parents:
diff changeset
     5
 *
25439
26d6d07eebc7 8044080: .out files for unicode, implicitThis and importChecks tests in tools/javac dir
sogoel
parents: 5520
diff changeset
     6
 * @compile/fail/ref=NewBeforeOuterConstructed2.out -XDrawDiagnostics  NewBeforeOuterConstructed2.java
10
06bc494ca11e Initial load
duke
parents:
diff changeset
     7
 */
06bc494ca11e Initial load
duke
parents:
diff changeset
     8
06bc494ca11e Initial load
duke
parents:
diff changeset
     9
public class NewBeforeOuterConstructed2 {
06bc494ca11e Initial load
duke
parents:
diff changeset
    10
    NewBeforeOuterConstructed2(Object o) {}
06bc494ca11e Initial load
duke
parents:
diff changeset
    11
    class Middle extends NewBeforeOuterConstructed2 {
06bc494ca11e Initial load
duke
parents:
diff changeset
    12
        Middle(int i) {
06bc494ca11e Initial load
duke
parents:
diff changeset
    13
            super(null);
06bc494ca11e Initial load
duke
parents:
diff changeset
    14
        }
06bc494ca11e Initial load
duke
parents:
diff changeset
    15
        Middle() {
06bc494ca11e Initial load
duke
parents:
diff changeset
    16
            // The 'new' below is illegal, as the outer
06bc494ca11e Initial load
duke
parents:
diff changeset
    17
            // constructor has not been called when the
06bc494ca11e Initial load
duke
parents:
diff changeset
    18
            // implicit reference to 'this' is evaluated
06bc494ca11e Initial load
duke
parents:
diff changeset
    19
            // during the new instance expression.
06bc494ca11e Initial load
duke
parents:
diff changeset
    20
            super(/*Middle.this.*/new Middle(1));
06bc494ca11e Initial load
duke
parents:
diff changeset
    21
        }
06bc494ca11e Initial load
duke
parents:
diff changeset
    22
        class Inner {}
06bc494ca11e Initial load
duke
parents:
diff changeset
    23
        void f() {
06bc494ca11e Initial load
duke
parents:
diff changeset
    24
            System.out.println("ok");
06bc494ca11e Initial load
duke
parents:
diff changeset
    25
        }
06bc494ca11e Initial load
duke
parents:
diff changeset
    26
    }
06bc494ca11e Initial load
duke
parents:
diff changeset
    27
    public static void main(String[] args) {
06bc494ca11e Initial load
duke
parents:
diff changeset
    28
        NewBeforeOuterConstructed2 c = new NewBeforeOuterConstructed2(new Object());
06bc494ca11e Initial load
duke
parents:
diff changeset
    29
        Middle m = c.new Middle();
06bc494ca11e Initial load
duke
parents:
diff changeset
    30
        m.f();
06bc494ca11e Initial load
duke
parents:
diff changeset
    31
    }
06bc494ca11e Initial load
duke
parents:
diff changeset
    32
}