< prev index next >

test/langtools/tools/javac/DefiniteAssignment/DA_DUConstructors.java

Print this page

 1 /*
 2  * @test /nodynamiccopyright/
 3  * @bug 8325805
 4  * @summary Permit non-superclass instance field assignments before this/super in constructors
 5  * @compile/fail/ref=DA_DUConstructors.out -XDrawDiagnostics DA_DUConstructors.java
 6  */
 7 
 8 public class DA_DUConstructors {
 9     // identity
10     class C1 {
11         final int x;
12         final int y = x + 1;
13         C1() {
14             x = 12;
15             super();
16         }
17     }
18 
19     class C2 {
20         final int x;
21         C2() {
22             this(x = 3); // error
23         }

 1 /*
 2  * @test /nodynamiccopyright/
 3  * @bug 8324873 8325805
 4  * @summary Permit non-superclass instance field assignments before this/super in constructors
 5  * @compile/fail/ref=DA_DUConstructors.out -XDrawDiagnostics DA_DUConstructors.java
 6  */
 7 
 8 public class DA_DUConstructors {
 9     // identity
10     class C1 {
11         final int x;
12         final int y = x + 1;
13         C1() {
14             x = 12;
15             super();
16         }
17     }
18 
19     class C2 {
20         final int x;
21         C2() {
22             this(x = 3); // error
23         }
< prev index next >