langtools/test/tools/javac/implicitThis/NewBeforeOuterConstructed.java
author sogoel
Fri, 29 Aug 2014 00:42:42 -0700
changeset 26274 02a5b23ee21c
parent 25439 26d6d07eebc7
permissions -rw-r--r--
8055074: Group 9a: golden files for tests in tools/javac dir Reviewed-by: jjg
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 4249111
06bc494ca11e Initial load
duke
parents:
diff changeset
     4
 * @summary 'new' of inner class should not be allowed unless outer is constructed
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=NewBeforeOuterConstructed.out -XDrawDiagnostics  NewBeforeOuterConstructed.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
import java.io.*;
06bc494ca11e Initial load
duke
parents:
diff changeset
    10
06bc494ca11e Initial load
duke
parents:
diff changeset
    11
public class NewBeforeOuterConstructed extends PrintStream {
06bc494ca11e Initial load
duke
parents:
diff changeset
    12
      private class NullOutputStream extends OutputStream {
06bc494ca11e Initial load
duke
parents:
diff changeset
    13
              public NullOutputStream() {
06bc494ca11e Initial load
duke
parents:
diff changeset
    14
                      super();
06bc494ca11e Initial load
duke
parents:
diff changeset
    15
              }
06bc494ca11e Initial load
duke
parents:
diff changeset
    16
              public void write(int b) { }
06bc494ca11e Initial load
duke
parents:
diff changeset
    17
              public void write(byte b[]) { }
06bc494ca11e Initial load
duke
parents:
diff changeset
    18
              public void write(byte b[], int off, int len) { }
06bc494ca11e Initial load
duke
parents:
diff changeset
    19
              public void flush() { }
06bc494ca11e Initial load
duke
parents:
diff changeset
    20
              public void close() { }
06bc494ca11e Initial load
duke
parents:
diff changeset
    21
      }
06bc494ca11e Initial load
duke
parents:
diff changeset
    22
       public NewBeforeOuterConstructed() {
06bc494ca11e Initial load
duke
parents:
diff changeset
    23
                // The 'new' below is illegal, as the outer
06bc494ca11e Initial load
duke
parents:
diff changeset
    24
                // constructor has not been called when the
06bc494ca11e Initial load
duke
parents:
diff changeset
    25
                // implicit reference to 'this' is evaluated
06bc494ca11e Initial load
duke
parents:
diff changeset
    26
                // during the new instance expression.
06bc494ca11e Initial load
duke
parents:
diff changeset
    27
              super(new NullOutputStream());
06bc494ca11e Initial load
duke
parents:
diff changeset
    28
      }
06bc494ca11e Initial load
duke
parents:
diff changeset
    29
}