test/tools/javac/DefiniteAssignment/T8039026.java

changeset 2376
12f99d1f23d9
parent 0
959103a6100f
     1.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     1.2 +++ b/test/tools/javac/DefiniteAssignment/T8039026.java	Wed Apr 30 23:29:43 2014 +0100
     1.3 @@ -0,0 +1,21 @@
     1.4 +/*
     1.5 + * @test /nodynamiccopyright/
     1.6 + * @bug 8039026
     1.7 + * @summary Definitely unassigned field can be accessed
     1.8 + * @compile/fail/ref=T8039026.out -XDrawDiagnostics T8039026.java
     1.9 + */
    1.10 +
    1.11 +public class T8039026 {
    1.12 +    final int x,y,z;
    1.13 +    final int a = this.y;  // <- error
    1.14 +    {
    1.15 +        int b = true ? this.x : 0;  // <- error
    1.16 +        System.out.println(this.x); // <- error
    1.17 +        this.y = 1;
    1.18 +    }
    1.19 +    T8039026() {
    1.20 +        this.x = 1;      // <- no error!
    1.21 +        this.y = 1;      // <- error
    1.22 +        this.z = this.x; // <- no error
    1.23 +    }
    1.24 +}

mercurial