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