< 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  * @enablePreview

 7  */
 8 
 9 public class DA_DUConstructors {
10     // identity
11     class C1 {
12         final int x;
13         final int y = x + 1;
14         C1() {
15             x = 12;
16             super();
17         }
18     }
19 
20     class C2 {
21         final int x;
22         C2() {
23             this(x = 3); // error
24         }
25         C2(int i) {
26             x = 4;

 1 /*
 2  * @test /nodynamiccopyright/
 3  * @bug 8324873 8325805
 4  * @summary Permit non-superclass instance field assignments before this/super in constructors

 5  * @enablePreview
 6  * @compile/fail/ref=DA_DUConstructors.out -XDrawDiagnostics DA_DUConstructors.java
 7  */
 8 
 9 public class DA_DUConstructors {
10     // identity
11     class C1 {
12         final int x;
13         final int y = x + 1;
14         C1() {
15             x = 12;
16             super();
17         }
18     }
19 
20     class C2 {
21         final int x;
22         C2() {
23             this(x = 3); // error
24         }
25         C2(int i) {
26             x = 4;
< prev index next >