1 /* 2 * @test /nodynamiccopyright/ 3 * @bug 8334258 4 * @summary Disallow early assignment if FLEXIBLE_CONSTRUCTORS preview feature is not enabled 5 * @compile/fail/ref=EarlyAssignmentNoPreview1.out --release 24 -XDrawDiagnostics EarlyAssignmentNoPreview1.java 6 */ 7 public class EarlyAssignmentNoPreview1 { 8 9 Runnable r; 10 11 public EarlyAssignmentNoPreview1() { 12 this(r = () -> System.out.println("hello")); 13 } 14 15 public EarlyAssignmentNoPreview1(Runnable r) { 16 } 17 18 public static void main(String[] args) { 19 new EarlyAssignmentNoPreview1(); 20 } 21 }