langtools/test/tools/javac/DefiniteAssignment/T8039026.java
author mcimadamore
Wed, 26 Oct 2016 15:41:25 +0100
changeset 41856 13a056e8f16e
parent 24218 9102c46a15dc
permissions -rw-r--r--
8168774: Polymorhic signature method check crashes javac Summary: Check for polysig method assumes arity is greater than zero Reviewed-by: vromero
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
24218
9102c46a15dc 8039026: Definitely unassigned field can be accessed
pgovereau
parents:
diff changeset
     1
/*
9102c46a15dc 8039026: Definitely unassigned field can be accessed
pgovereau
parents:
diff changeset
     2
 * @test /nodynamiccopyright/
9102c46a15dc 8039026: Definitely unassigned field can be accessed
pgovereau
parents:
diff changeset
     3
 * @bug 8039026
9102c46a15dc 8039026: Definitely unassigned field can be accessed
pgovereau
parents:
diff changeset
     4
 * @summary Definitely unassigned field can be accessed
9102c46a15dc 8039026: Definitely unassigned field can be accessed
pgovereau
parents:
diff changeset
     5
 * @compile/fail/ref=T8039026.out -XDrawDiagnostics T8039026.java
9102c46a15dc 8039026: Definitely unassigned field can be accessed
pgovereau
parents:
diff changeset
     6
 */
9102c46a15dc 8039026: Definitely unassigned field can be accessed
pgovereau
parents:
diff changeset
     7
9102c46a15dc 8039026: Definitely unassigned field can be accessed
pgovereau
parents:
diff changeset
     8
public class T8039026 {
9102c46a15dc 8039026: Definitely unassigned field can be accessed
pgovereau
parents:
diff changeset
     9
    final int x,y,z;
9102c46a15dc 8039026: Definitely unassigned field can be accessed
pgovereau
parents:
diff changeset
    10
    final int a = this.y;  // <- error
9102c46a15dc 8039026: Definitely unassigned field can be accessed
pgovereau
parents:
diff changeset
    11
    {
9102c46a15dc 8039026: Definitely unassigned field can be accessed
pgovereau
parents:
diff changeset
    12
        int b = true ? this.x : 0;  // <- error
9102c46a15dc 8039026: Definitely unassigned field can be accessed
pgovereau
parents:
diff changeset
    13
        System.out.println(this.x); // <- error
9102c46a15dc 8039026: Definitely unassigned field can be accessed
pgovereau
parents:
diff changeset
    14
        this.y = 1;
9102c46a15dc 8039026: Definitely unassigned field can be accessed
pgovereau
parents:
diff changeset
    15
    }
9102c46a15dc 8039026: Definitely unassigned field can be accessed
pgovereau
parents:
diff changeset
    16
    T8039026() {
9102c46a15dc 8039026: Definitely unassigned field can be accessed
pgovereau
parents:
diff changeset
    17
        this.x = 1;      // <- no error!
9102c46a15dc 8039026: Definitely unassigned field can be accessed
pgovereau
parents:
diff changeset
    18
        this.y = 1;      // <- error
9102c46a15dc 8039026: Definitely unassigned field can be accessed
pgovereau
parents:
diff changeset
    19
        this.z = this.x; // <- no error
9102c46a15dc 8039026: Definitely unassigned field can be accessed
pgovereau
parents:
diff changeset
    20
    }
9102c46a15dc 8039026: Definitely unassigned field can be accessed
pgovereau
parents:
diff changeset
    21
}