diff --git a/src/jdk.compiler/share/classes/com/sun/tools/javac/code/Preview.java b/src/jdk.compiler/share/classes/com/sun/tools/javac/code/Preview.java index 2d0f44200c110..d1e64e90a07cc 100644 --- a/src/jdk.compiler/share/classes/com/sun/tools/javac/code/Preview.java +++ b/src/jdk.compiler/share/classes/com/sun/tools/javac/code/Preview.java @@ -226,7 +226,6 @@ public boolean isEnabled() { */ public boolean isPreview(Feature feature) { return switch (feature) { - case FLEXIBLE_CONSTRUCTORS -> true; case PRIMITIVE_PATTERNS -> true; //Note: this is a backdoor which allows to optionally treat all features as 'preview' (for testing). //When real preview features will be added, this method can be implemented to return 'true' diff --git a/src/jdk.compiler/share/classes/com/sun/tools/javac/code/Source.java b/src/jdk.compiler/share/classes/com/sun/tools/javac/code/Source.java index e3585dd398b90..b0b82fa573482 100644 --- a/src/jdk.compiler/share/classes/com/sun/tools/javac/code/Source.java +++ b/src/jdk.compiler/share/classes/com/sun/tools/javac/code/Source.java @@ -266,7 +266,7 @@ public enum Feature { WARN_ON_ILLEGAL_UTF8(MIN, JDK21), UNNAMED_VARIABLES(JDK22, Fragments.FeatureUnnamedVariables, DiagKind.PLURAL), PRIMITIVE_PATTERNS(JDK23, Fragments.FeaturePrimitivePatterns, DiagKind.PLURAL), - FLEXIBLE_CONSTRUCTORS(JDK22, Fragments.FeatureFlexibleConstructors, DiagKind.NORMAL), + FLEXIBLE_CONSTRUCTORS(JDK25, Fragments.FeatureFlexibleConstructors, DiagKind.NORMAL), MODULE_IMPORTS(JDK25, Fragments.FeatureModuleImports, DiagKind.PLURAL), JAVA_BASE_TRANSITIVE(JDK25, Fragments.FeatureJavaBaseTransitive, DiagKind.PLURAL), PRIVATE_MEMBERS_IN_PERMITS_CLAUSE(JDK19), diff --git a/test/langtools/tools/javac/DefiniteAssignment/DA_DUConstructors.java b/test/langtools/tools/javac/DefiniteAssignment/DA_DUConstructors.java index 7947b69b83015..60d79d931292d 100644 --- a/test/langtools/tools/javac/DefiniteAssignment/DA_DUConstructors.java +++ b/test/langtools/tools/javac/DefiniteAssignment/DA_DUConstructors.java @@ -3,7 +3,6 @@ * @bug 8325805 * @summary Permit non-superclass instance field assignments before this/super in constructors * @compile/fail/ref=DA_DUConstructors.out -XDrawDiagnostics DA_DUConstructors.java - * @enablePreview */ public class DA_DUConstructors { diff --git a/test/langtools/tools/javac/DefiniteAssignment/DA_DUConstructors.out b/test/langtools/tools/javac/DefiniteAssignment/DA_DUConstructors.out index 78cd3d314a80b..03cd6c2574b0f 100644 --- a/test/langtools/tools/javac/DefiniteAssignment/DA_DUConstructors.out +++ b/test/langtools/tools/javac/DefiniteAssignment/DA_DUConstructors.out @@ -1,5 +1,3 @@ -DA_DUConstructors.java:23:17: compiler.err.var.might.already.be.assigned: x -DA_DUConstructors.java:42:23: compiler.err.var.might.not.have.been.initialized: x -- compiler.note.preview.filename: DA_DUConstructors.java, DEFAULT -- compiler.note.preview.recompile +DA_DUConstructors.java:22:17: compiler.err.var.might.already.be.assigned: x +DA_DUConstructors.java:41:23: compiler.err.var.might.not.have.been.initialized: x 2 errors diff --git a/test/langtools/tools/javac/LocalClassCtorPrologue.java b/test/langtools/tools/javac/LocalClassCtorPrologue.java index 2a7178ed85725..b5bd35f474570 100644 --- a/test/langtools/tools/javac/LocalClassCtorPrologue.java +++ b/test/langtools/tools/javac/LocalClassCtorPrologue.java @@ -3,7 +3,6 @@ * @bug 8328649 * @summary Verify local classes in constructor prologues don't have enclosing instances * @compile/fail/ref=LocalClassCtorPrologue.out -XDrawDiagnostics LocalClassCtorPrologue.java - * @enablePreview */ class LocalClassCtorPrologue { diff --git a/test/langtools/tools/javac/LocalClassCtorPrologue.out b/test/langtools/tools/javac/LocalClassCtorPrologue.out index 65f3418825d89..086addaacd048 100644 --- a/test/langtools/tools/javac/LocalClassCtorPrologue.out +++ b/test/langtools/tools/javac/LocalClassCtorPrologue.out @@ -1,4 +1,2 @@ -LocalClassCtorPrologue.java:16:17: compiler.err.cant.ref.before.ctor.called: x -- compiler.note.preview.filename: LocalClassCtorPrologue.java, DEFAULT -- compiler.note.preview.recompile +LocalClassCtorPrologue.java:15:17: compiler.err.cant.ref.before.ctor.called: x 1 error diff --git a/test/langtools/tools/javac/SuperInit/EarlyAssignmentNoPreview1.java b/test/langtools/tools/javac/SuperInit/EarlyAssignmentNoPreview1.java index abb6bacbc8fc9..0d7938d7216de 100644 --- a/test/langtools/tools/javac/SuperInit/EarlyAssignmentNoPreview1.java +++ b/test/langtools/tools/javac/SuperInit/EarlyAssignmentNoPreview1.java @@ -2,7 +2,7 @@ * @test /nodynamiccopyright/ * @bug 8334258 * @summary Disallow early assignment if FLEXIBLE_CONSTRUCTORS preview feature is not enabled - * @compile/fail/ref=EarlyAssignmentNoPreview1.out -XDrawDiagnostics EarlyAssignmentNoPreview1.java + * @compile/fail/ref=EarlyAssignmentNoPreview1.out --release 24 -XDrawDiagnostics EarlyAssignmentNoPreview1.java */ public class EarlyAssignmentNoPreview1 { diff --git a/test/langtools/tools/javac/SuperInit/EarlyAssignmentNoPreview1.out b/test/langtools/tools/javac/SuperInit/EarlyAssignmentNoPreview1.out index 6c5afbbd12bb4..c28d53b37742e 100644 --- a/test/langtools/tools/javac/SuperInit/EarlyAssignmentNoPreview1.out +++ b/test/langtools/tools/javac/SuperInit/EarlyAssignmentNoPreview1.out @@ -1,2 +1,2 @@ -EarlyAssignmentNoPreview1.java:12:14: compiler.err.preview.feature.disabled: (compiler.misc.feature.flexible.constructors) +EarlyAssignmentNoPreview1.java:12:14: compiler.err.feature.not.supported.in.source: (compiler.misc.feature.flexible.constructors), 24, 25 1 error diff --git a/test/langtools/tools/javac/SuperInit/EarlyAssignmentNoPreview2.java b/test/langtools/tools/javac/SuperInit/EarlyAssignmentNoPreview2.java index 3c33734f42a55..64332244e0198 100644 --- a/test/langtools/tools/javac/SuperInit/EarlyAssignmentNoPreview2.java +++ b/test/langtools/tools/javac/SuperInit/EarlyAssignmentNoPreview2.java @@ -2,7 +2,7 @@ * @test /nodynamiccopyright/ * @bug 8334258 * @summary Disallow early assignment if FLEXIBLE_CONSTRUCTORS preview feature is not enabled - * @compile/fail/ref=EarlyAssignmentNoPreview2.out -XDrawDiagnostics EarlyAssignmentNoPreview2.java + * @compile/fail/ref=EarlyAssignmentNoPreview2.out --release 24 -XDrawDiagnostics EarlyAssignmentNoPreview2.java */ public class EarlyAssignmentNoPreview2 { diff --git a/test/langtools/tools/javac/SuperInit/EarlyAssignmentNoPreview2.out b/test/langtools/tools/javac/SuperInit/EarlyAssignmentNoPreview2.out index 38fb885684e1d..1250c714c4a5e 100644 --- a/test/langtools/tools/javac/SuperInit/EarlyAssignmentNoPreview2.out +++ b/test/langtools/tools/javac/SuperInit/EarlyAssignmentNoPreview2.out @@ -1,2 +1,2 @@ -EarlyAssignmentNoPreview2.java:12:14: compiler.err.preview.feature.disabled: (compiler.misc.feature.flexible.constructors) +EarlyAssignmentNoPreview2.java:12:14: compiler.err.feature.not.supported.in.source: (compiler.misc.feature.flexible.constructors), 24, 25 1 error diff --git a/test/langtools/tools/javac/SuperInit/EarlyAssignmentNoPreview3.java b/test/langtools/tools/javac/SuperInit/EarlyAssignmentNoPreview3.java index f6269f2cb1fdc..e021d80e6c18d 100644 --- a/test/langtools/tools/javac/SuperInit/EarlyAssignmentNoPreview3.java +++ b/test/langtools/tools/javac/SuperInit/EarlyAssignmentNoPreview3.java @@ -2,7 +2,7 @@ * @test /nodynamiccopyright/ * @bug 8334258 * @summary Disallow early assignment if FLEXIBLE_CONSTRUCTORS preview feature is not enabled - * @compile/fail/ref=EarlyAssignmentNoPreview3.out -XDrawDiagnostics EarlyAssignmentNoPreview3.java + * @compile/fail/ref=EarlyAssignmentNoPreview3.out --release 24 -XDrawDiagnostics EarlyAssignmentNoPreview3.java */ public class EarlyAssignmentNoPreview3 { diff --git a/test/langtools/tools/javac/SuperInit/EarlyAssignmentNoPreview3.out b/test/langtools/tools/javac/SuperInit/EarlyAssignmentNoPreview3.out index def9f4f3722f1..f1ccf9cfa7dcb 100644 --- a/test/langtools/tools/javac/SuperInit/EarlyAssignmentNoPreview3.out +++ b/test/langtools/tools/javac/SuperInit/EarlyAssignmentNoPreview3.out @@ -1,2 +1,2 @@ -EarlyAssignmentNoPreview3.java:12:39: compiler.err.preview.feature.disabled: (compiler.misc.feature.flexible.constructors) +EarlyAssignmentNoPreview3.java:12:39: compiler.err.feature.not.supported.in.source: (compiler.misc.feature.flexible.constructors), 24, 25 1 error diff --git a/test/langtools/tools/javac/SuperInit/EarlyAssignments.java b/test/langtools/tools/javac/SuperInit/EarlyAssignments.java index c3cad5d7016ca..0168ed9f4b4e3 100644 --- a/test/langtools/tools/javac/SuperInit/EarlyAssignments.java +++ b/test/langtools/tools/javac/SuperInit/EarlyAssignments.java @@ -3,7 +3,6 @@ * @bug 8325805 * @summary Permit non-superclass instance field assignments before this/super in constructors * @compile/fail/ref=EarlyAssignments.out -XDrawDiagnostics EarlyAssignments.java - * @enablePreview */ public class EarlyAssignments { diff --git a/test/langtools/tools/javac/SuperInit/EarlyAssignments.out b/test/langtools/tools/javac/SuperInit/EarlyAssignments.out index 38182c2d3126a..ac765c141e794 100644 --- a/test/langtools/tools/javac/SuperInit/EarlyAssignments.out +++ b/test/langtools/tools/javac/SuperInit/EarlyAssignments.out @@ -1,29 +1,27 @@ -EarlyAssignments.java:21:17: compiler.err.cant.ref.before.ctor.called: x -EarlyAssignments.java:22:17: compiler.err.cant.ref.before.ctor.called: this -EarlyAssignments.java:23:23: compiler.err.cant.ref.before.ctor.called: this -EarlyAssignments.java:31:21: compiler.err.cant.ref.before.ctor.called: super -EarlyAssignments.java:32:21: compiler.err.cant.ref.before.ctor.called: x -EarlyAssignments.java:33:26: compiler.err.cant.ref.before.ctor.called: x -EarlyAssignments.java:34:34: compiler.err.cant.ref.before.ctor.called: x -EarlyAssignments.java:36:36: compiler.err.cant.ref.before.ctor.called: this -EarlyAssignments.java:40:17: compiler.err.cant.ref.before.ctor.called: x -EarlyAssignments.java:44:21: compiler.err.cant.ref.before.ctor.called: x -EarlyAssignments.java:48:22: compiler.err.cant.ref.before.ctor.called: x -EarlyAssignments.java:66:13: compiler.err.cant.ref.before.ctor.called: x -EarlyAssignments.java:67:17: compiler.err.cant.ref.before.ctor.called: x -EarlyAssignments.java:68:25: compiler.err.cant.ref.before.ctor.called: this -EarlyAssignments.java:69:31: compiler.err.cant.ref.before.ctor.called: this -EarlyAssignments.java:98:17: compiler.err.cant.ref.before.ctor.called: x -EarlyAssignments.java:104:22: compiler.err.cant.ref.before.ctor.called: this -EarlyAssignments.java:110:35: compiler.err.cant.ref.before.ctor.called: this -EarlyAssignments.java:119:17: compiler.err.cant.ref.before.ctor.called: x -EarlyAssignments.java:124:22: compiler.err.cant.ref.before.ctor.called: x -EarlyAssignments.java:129:29: compiler.err.cant.ref.before.ctor.called: x -EarlyAssignments.java:134:17: compiler.err.cant.ref.before.ctor.called: super -EarlyAssignments.java:139:23: compiler.err.cant.ref.before.ctor.called: this -EarlyAssignments.java:148:13: compiler.err.cant.assign.initialized.before.ctor.called: x -EarlyAssignments.java:157:13: compiler.err.cant.assign.val.to.var: final, x -EarlyAssignments.java:168:13: compiler.err.cant.ref.before.ctor.called: this -- compiler.note.preview.filename: EarlyAssignments.java, DEFAULT -- compiler.note.preview.recompile +EarlyAssignments.java:20:17: compiler.err.cant.ref.before.ctor.called: x +EarlyAssignments.java:21:17: compiler.err.cant.ref.before.ctor.called: this +EarlyAssignments.java:22:23: compiler.err.cant.ref.before.ctor.called: this +EarlyAssignments.java:30:21: compiler.err.cant.ref.before.ctor.called: super +EarlyAssignments.java:31:21: compiler.err.cant.ref.before.ctor.called: x +EarlyAssignments.java:32:26: compiler.err.cant.ref.before.ctor.called: x +EarlyAssignments.java:33:34: compiler.err.cant.ref.before.ctor.called: x +EarlyAssignments.java:35:36: compiler.err.cant.ref.before.ctor.called: this +EarlyAssignments.java:39:17: compiler.err.cant.ref.before.ctor.called: x +EarlyAssignments.java:43:21: compiler.err.cant.ref.before.ctor.called: x +EarlyAssignments.java:47:22: compiler.err.cant.ref.before.ctor.called: x +EarlyAssignments.java:65:13: compiler.err.cant.ref.before.ctor.called: x +EarlyAssignments.java:66:17: compiler.err.cant.ref.before.ctor.called: x +EarlyAssignments.java:67:25: compiler.err.cant.ref.before.ctor.called: this +EarlyAssignments.java:68:31: compiler.err.cant.ref.before.ctor.called: this +EarlyAssignments.java:97:17: compiler.err.cant.ref.before.ctor.called: x +EarlyAssignments.java:103:22: compiler.err.cant.ref.before.ctor.called: this +EarlyAssignments.java:109:35: compiler.err.cant.ref.before.ctor.called: this +EarlyAssignments.java:118:17: compiler.err.cant.ref.before.ctor.called: x +EarlyAssignments.java:123:22: compiler.err.cant.ref.before.ctor.called: x +EarlyAssignments.java:128:29: compiler.err.cant.ref.before.ctor.called: x +EarlyAssignments.java:133:17: compiler.err.cant.ref.before.ctor.called: super +EarlyAssignments.java:138:23: compiler.err.cant.ref.before.ctor.called: this +EarlyAssignments.java:147:13: compiler.err.cant.assign.initialized.before.ctor.called: x +EarlyAssignments.java:156:13: compiler.err.cant.assign.val.to.var: final, x +EarlyAssignments.java:167:13: compiler.err.cant.ref.before.ctor.called: this 26 errors diff --git a/test/langtools/tools/javac/SuperInit/EarlyInnerAccessErrorMessageTest.java b/test/langtools/tools/javac/SuperInit/EarlyInnerAccessErrorMessageTest.java index a8ee3a2aea5c2..c82795432446c 100644 --- a/test/langtools/tools/javac/SuperInit/EarlyInnerAccessErrorMessageTest.java +++ b/test/langtools/tools/javac/SuperInit/EarlyInnerAccessErrorMessageTest.java @@ -3,7 +3,6 @@ * @bug 8334488 * @summary Verify the error message generated for early access from inner class * @compile/fail/ref=EarlyInnerAccessErrorMessageTest.out -XDrawDiagnostics EarlyInnerAccessErrorMessageTest.java - * @enablePreview */ public class EarlyInnerAccessErrorMessageTest { int x; diff --git a/test/langtools/tools/javac/SuperInit/EarlyInnerAccessErrorMessageTest.out b/test/langtools/tools/javac/SuperInit/EarlyInnerAccessErrorMessageTest.out index a8d690a4c2361..2bea02bed107b 100644 --- a/test/langtools/tools/javac/SuperInit/EarlyInnerAccessErrorMessageTest.out +++ b/test/langtools/tools/javac/SuperInit/EarlyInnerAccessErrorMessageTest.out @@ -1,4 +1,2 @@ -EarlyInnerAccessErrorMessageTest.java:12:34: compiler.err.cant.ref.before.ctor.called: x -- compiler.note.preview.filename: EarlyInnerAccessErrorMessageTest.java, DEFAULT -- compiler.note.preview.recompile +EarlyInnerAccessErrorMessageTest.java:11:34: compiler.err.cant.ref.before.ctor.called: x 1 error diff --git a/test/langtools/tools/javac/SuperInit/EarlyLambdaReturn.java b/test/langtools/tools/javac/SuperInit/EarlyLambdaReturn.java index fd63f4c1a3b17..a56974ea25283 100644 --- a/test/langtools/tools/javac/SuperInit/EarlyLambdaReturn.java +++ b/test/langtools/tools/javac/SuperInit/EarlyLambdaReturn.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2024, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2024, 2025, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -24,7 +24,6 @@ * @test * @bug 8345438 * @summary Verify 'return' allowed in a lambda declared in an early construction context - * @enablePreview */ public class EarlyLambdaReturn { diff --git a/test/langtools/tools/javac/SuperInit/EarlyLocalClass.java b/test/langtools/tools/javac/SuperInit/EarlyLocalClass.java index 1c68de603fbd5..5ac5aba82edf8 100644 --- a/test/langtools/tools/javac/SuperInit/EarlyLocalClass.java +++ b/test/langtools/tools/javac/SuperInit/EarlyLocalClass.java @@ -3,7 +3,6 @@ * @bug 8325805 * @summary Verify local class in early construction context has no outer instance * @compile/fail/ref=EarlyLocalClass.out -XDrawDiagnostics EarlyLocalClass.java - * @enablePreview */ public class EarlyLocalClass { EarlyLocalClass() { diff --git a/test/langtools/tools/javac/SuperInit/EarlyLocalClass.out b/test/langtools/tools/javac/SuperInit/EarlyLocalClass.out index ee01f9c403d5b..1024b5bdf2667 100644 --- a/test/langtools/tools/javac/SuperInit/EarlyLocalClass.out +++ b/test/langtools/tools/javac/SuperInit/EarlyLocalClass.out @@ -1,4 +1,2 @@ -EarlyLocalClass.java:12:32: compiler.err.cant.ref.before.ctor.called: this -- compiler.note.preview.filename: EarlyLocalClass.java, DEFAULT -- compiler.note.preview.recompile +EarlyLocalClass.java:11:32: compiler.err.cant.ref.before.ctor.called: this 1 error diff --git a/test/langtools/tools/javac/SuperInit/EarlyLocalCtorRef.java b/test/langtools/tools/javac/SuperInit/EarlyLocalCtorRef.java index 3346d6ff4f7f9..6d0c2c74dfefd 100644 --- a/test/langtools/tools/javac/SuperInit/EarlyLocalCtorRef.java +++ b/test/langtools/tools/javac/SuperInit/EarlyLocalCtorRef.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2024, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2024, 2025, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -24,7 +24,6 @@ * @test * @bug 8334248 * @summary Allow early construction local class constructor method references - * @enablePreview */ import java.util.function.Supplier; diff --git a/test/langtools/tools/javac/SuperInit/EarlyLocalTest1.java b/test/langtools/tools/javac/SuperInit/EarlyLocalTest1.java index 5d9060da83c26..a51189c11c9eb 100644 --- a/test/langtools/tools/javac/SuperInit/EarlyLocalTest1.java +++ b/test/langtools/tools/javac/SuperInit/EarlyLocalTest1.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2024, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2024, 2025, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -24,7 +24,6 @@ * @test * @bug 8333313 * @summary Verify references to local classes declared in early construction contexts - * @enablePreview */ public class EarlyLocalTest1 { diff --git a/test/langtools/tools/javac/SuperInit/EarlyLocalTest2.java b/test/langtools/tools/javac/SuperInit/EarlyLocalTest2.java index ba90f06dc5e35..09dbc66e2d370 100644 --- a/test/langtools/tools/javac/SuperInit/EarlyLocalTest2.java +++ b/test/langtools/tools/javac/SuperInit/EarlyLocalTest2.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2024, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2024, 2025, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -24,7 +24,6 @@ * @test * @bug 8333313 * @summary Verify references to local classes declared in early construction contexts - * @enablePreview */ public class EarlyLocalTest2 { diff --git a/test/langtools/tools/javac/SuperInit/EarlyLocalTest3.java b/test/langtools/tools/javac/SuperInit/EarlyLocalTest3.java index bf8d6faa09983..34d280532c3d5 100644 --- a/test/langtools/tools/javac/SuperInit/EarlyLocalTest3.java +++ b/test/langtools/tools/javac/SuperInit/EarlyLocalTest3.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2024, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2024, 2025, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -24,7 +24,6 @@ * @test * @bug 8333313 * @summary Verify references to local classes declared in early construction contexts - * @enablePreview */ public class EarlyLocalTest3 { diff --git a/test/langtools/tools/javac/SuperInit/EarlyLocalTest4.java b/test/langtools/tools/javac/SuperInit/EarlyLocalTest4.java index cce6092f60696..7f6fa032ec7ad 100644 --- a/test/langtools/tools/javac/SuperInit/EarlyLocalTest4.java +++ b/test/langtools/tools/javac/SuperInit/EarlyLocalTest4.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2024, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2024, 2025, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -24,7 +24,6 @@ * @test * @bug 8333313 * @summary Verify references to local classes declared in early construction contexts - * @enablePreview */ public class EarlyLocalTest4 { diff --git a/test/langtools/tools/javac/SuperInit/EarlyLocalTest5.java b/test/langtools/tools/javac/SuperInit/EarlyLocalTest5.java index 6858e068af839..c75b97c6beb0a 100644 --- a/test/langtools/tools/javac/SuperInit/EarlyLocalTest5.java +++ b/test/langtools/tools/javac/SuperInit/EarlyLocalTest5.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2024, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2024, 2025, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -24,7 +24,6 @@ * @test * @bug 8333313 * @summary Verify references to local classes declared in early construction contexts - * @enablePreview */ import java.util.concurrent.atomic.AtomicReference; diff --git a/test/langtools/tools/javac/SuperInit/EarlyLocalTest6.java b/test/langtools/tools/javac/SuperInit/EarlyLocalTest6.java index 742496a48d547..35eda1a5257d9 100644 --- a/test/langtools/tools/javac/SuperInit/EarlyLocalTest6.java +++ b/test/langtools/tools/javac/SuperInit/EarlyLocalTest6.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2024, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2024, 2025, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -24,7 +24,6 @@ * @test * @bug 8333313 * @summary Verify references to local classes declared in early construction contexts - * @enablePreview */ import java.util.concurrent.atomic.AtomicReference; diff --git a/test/langtools/tools/javac/SuperInit/EarlyLocalTest7.java b/test/langtools/tools/javac/SuperInit/EarlyLocalTest7.java index 1ce63bc04ba6c..885783eb9b080 100644 --- a/test/langtools/tools/javac/SuperInit/EarlyLocalTest7.java +++ b/test/langtools/tools/javac/SuperInit/EarlyLocalTest7.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2024, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2024, 2025, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -24,7 +24,6 @@ * @test * @bug 8333313 * @summary Verify references to local classes declared in early construction contexts - * @enablePreview */ import java.util.concurrent.atomic.AtomicReference; diff --git a/test/langtools/tools/javac/SuperInit/EarlyLocalTest8.java b/test/langtools/tools/javac/SuperInit/EarlyLocalTest8.java index 806903e901700..d09e12fcd5d70 100644 --- a/test/langtools/tools/javac/SuperInit/EarlyLocalTest8.java +++ b/test/langtools/tools/javac/SuperInit/EarlyLocalTest8.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2024, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2024, 2025, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -24,7 +24,6 @@ * @test * @bug 8333313 * @summary Verify references to local classes declared in early construction contexts - * @enablePreview */ import java.util.concurrent.atomic.AtomicReference; diff --git a/test/langtools/tools/javac/SuperInit/LambdaLocalEarlyCrash.java b/test/langtools/tools/javac/SuperInit/LambdaLocalEarlyCrash.java index 660e7d19f4e01..2d2f8c030ee7f 100644 --- a/test/langtools/tools/javac/SuperInit/LambdaLocalEarlyCrash.java +++ b/test/langtools/tools/javac/SuperInit/LambdaLocalEarlyCrash.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2024, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2024, 2025, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -24,7 +24,6 @@ * @test * @bug 8334037 * @summary Test for compiler crash when local class created in early lambda - * @enablePreview */ public class LambdaLocalEarlyCrash { diff --git a/test/langtools/tools/javac/SuperInit/LambdaOuterCapture.java b/test/langtools/tools/javac/SuperInit/LambdaOuterCapture.java index 261b23dc298f8..f1f8535e2dd94 100644 --- a/test/langtools/tools/javac/SuperInit/LambdaOuterCapture.java +++ b/test/langtools/tools/javac/SuperInit/LambdaOuterCapture.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2024, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2024, 2025, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -24,7 +24,6 @@ * @test * @bug 8334252 * @summary Test lambda declared in early construction context - * @enablePreview */ public class LambdaOuterCapture { diff --git a/test/langtools/tools/javac/SuperInit/MultiLevelOuterInstance.java b/test/langtools/tools/javac/SuperInit/MultiLevelOuterInstance.java index e47e70a3bdc56..5bdec42f4839c 100644 --- a/test/langtools/tools/javac/SuperInit/MultiLevelOuterInstance.java +++ b/test/langtools/tools/javac/SuperInit/MultiLevelOuterInstance.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2024, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2024, 2025, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -24,7 +24,6 @@ * @test * @bug 8334121 * @summary Anonymous class capturing two enclosing instances fails to compile - * @enablePreview */ public class MultiLevelOuterInstance { diff --git a/test/langtools/tools/javac/SuperInit/SuperInitFails.java b/test/langtools/tools/javac/SuperInit/SuperInitFails.java index feb5b81c1b043..f9cfe5cd7c42c 100644 --- a/test/langtools/tools/javac/SuperInit/SuperInitFails.java +++ b/test/langtools/tools/javac/SuperInit/SuperInitFails.java @@ -3,7 +3,6 @@ * @bug 8194743 * @summary Permit additional statements before this/super in constructors * @compile/fail/ref=SuperInitFails.out -XDrawDiagnostics SuperInitFails.java - * @enablePreview */ import java.util.concurrent.atomic.AtomicReference; public class SuperInitFails extends AtomicReference implements Iterable { diff --git a/test/langtools/tools/javac/SuperInit/SuperInitFails.out b/test/langtools/tools/javac/SuperInit/SuperInitFails.out index a6cabb6f5ed6e..1a8e8797135ec 100644 --- a/test/langtools/tools/javac/SuperInit/SuperInitFails.out +++ b/test/langtools/tools/javac/SuperInit/SuperInitFails.out @@ -1,36 +1,34 @@ -SuperInitFails.java:57:9: compiler.err.cant.ref.before.ctor.called: hashCode() -SuperInitFails.java:62:9: compiler.err.cant.ref.before.ctor.called: this -SuperInitFails.java:67:9: compiler.err.cant.ref.before.ctor.called: super -SuperInitFails.java:72:23: compiler.err.cant.ref.before.ctor.called: this -SuperInitFails.java:77:23: compiler.err.cant.ref.before.ctor.called: super -SuperInitFails.java:94:9: compiler.err.cant.ref.before.ctor.called: this -SuperInitFails.java:99:33: compiler.err.cant.ref.before.ctor.called: this -SuperInitFails.java:104:14: compiler.err.cant.ref.before.ctor.called: this -SuperInitFails.java:108:20: compiler.err.not.encl.class: java.lang.Object -SuperInitFails.java:112:17: compiler.err.cant.ref.before.ctor.called: super -SuperInitFails.java:119:22: compiler.err.call.must.only.appear.in.ctor -SuperInitFails.java:125:9: compiler.err.cant.ref.before.ctor.called: this -SuperInitFails.java:133:9: compiler.err.non.canonical.constructor.invoke.another.constructor: SuperInitFails.Record1 -SuperInitFails.java:138:9: compiler.err.non.canonical.constructor.invoke.another.constructor: SuperInitFails.Record2 -SuperInitFails.java:155:31: compiler.err.cant.ref.before.ctor.called: x -SuperInitFails.java:159:15: compiler.err.cant.ref.before.ctor.called: this -SuperInitFails.java:168:13: compiler.err.cant.ref.before.ctor.called: x -SuperInitFails.java:172:17: compiler.err.cant.ref.before.ctor.called: x -SuperInitFails.java:176:24: compiler.err.cant.ref.before.ctor.called: x -SuperInitFails.java:180:18: compiler.err.cant.ref.before.ctor.called: x -SuperInitFails.java:186:28: compiler.err.cant.ref.before.ctor.called: this -SuperInitFails.java:195:25: compiler.err.return.before.superclass.initialized -SuperInitFails.java:200:33: compiler.err.ctor.calls.not.allowed.here -SuperInitFails.java:205:29: compiler.err.redundant.superclass.init -SuperInitFails.java:33:13: compiler.err.call.must.only.appear.in.ctor -SuperInitFails.java:37:14: compiler.err.call.must.only.appear.in.ctor -SuperInitFails.java:41:14: compiler.err.call.must.only.appear.in.ctor -SuperInitFails.java:45:13: compiler.err.call.must.only.appear.in.ctor -SuperInitFails.java:49:33: compiler.err.call.must.only.appear.in.ctor -SuperInitFails.java:53:32: compiler.err.call.must.only.appear.in.ctor -SuperInitFails.java:83:18: compiler.err.ctor.calls.not.allowed.here -SuperInitFails.java:89:13: compiler.err.return.before.superclass.initialized -SuperInitFails.java:150:18: compiler.err.call.must.only.appear.in.ctor -- compiler.note.preview.filename: SuperInitFails.java, DEFAULT -- compiler.note.preview.recompile +SuperInitFails.java:56:9: compiler.err.cant.ref.before.ctor.called: hashCode() +SuperInitFails.java:61:9: compiler.err.cant.ref.before.ctor.called: this +SuperInitFails.java:66:9: compiler.err.cant.ref.before.ctor.called: super +SuperInitFails.java:71:23: compiler.err.cant.ref.before.ctor.called: this +SuperInitFails.java:76:23: compiler.err.cant.ref.before.ctor.called: super +SuperInitFails.java:93:9: compiler.err.cant.ref.before.ctor.called: this +SuperInitFails.java:98:33: compiler.err.cant.ref.before.ctor.called: this +SuperInitFails.java:103:14: compiler.err.cant.ref.before.ctor.called: this +SuperInitFails.java:107:20: compiler.err.not.encl.class: java.lang.Object +SuperInitFails.java:111:17: compiler.err.cant.ref.before.ctor.called: super +SuperInitFails.java:118:22: compiler.err.call.must.only.appear.in.ctor +SuperInitFails.java:124:9: compiler.err.cant.ref.before.ctor.called: this +SuperInitFails.java:132:9: compiler.err.non.canonical.constructor.invoke.another.constructor: SuperInitFails.Record1 +SuperInitFails.java:137:9: compiler.err.non.canonical.constructor.invoke.another.constructor: SuperInitFails.Record2 +SuperInitFails.java:154:31: compiler.err.cant.ref.before.ctor.called: x +SuperInitFails.java:158:15: compiler.err.cant.ref.before.ctor.called: this +SuperInitFails.java:167:13: compiler.err.cant.ref.before.ctor.called: x +SuperInitFails.java:171:17: compiler.err.cant.ref.before.ctor.called: x +SuperInitFails.java:175:24: compiler.err.cant.ref.before.ctor.called: x +SuperInitFails.java:179:18: compiler.err.cant.ref.before.ctor.called: x +SuperInitFails.java:185:28: compiler.err.cant.ref.before.ctor.called: this +SuperInitFails.java:194:25: compiler.err.return.before.superclass.initialized +SuperInitFails.java:199:33: compiler.err.ctor.calls.not.allowed.here +SuperInitFails.java:204:29: compiler.err.redundant.superclass.init +SuperInitFails.java:32:13: compiler.err.call.must.only.appear.in.ctor +SuperInitFails.java:36:14: compiler.err.call.must.only.appear.in.ctor +SuperInitFails.java:40:14: compiler.err.call.must.only.appear.in.ctor +SuperInitFails.java:44:13: compiler.err.call.must.only.appear.in.ctor +SuperInitFails.java:48:33: compiler.err.call.must.only.appear.in.ctor +SuperInitFails.java:52:32: compiler.err.call.must.only.appear.in.ctor +SuperInitFails.java:82:18: compiler.err.ctor.calls.not.allowed.here +SuperInitFails.java:88:13: compiler.err.return.before.superclass.initialized +SuperInitFails.java:149:18: compiler.err.call.must.only.appear.in.ctor 33 errors diff --git a/test/langtools/tools/javac/SuperInit/SuperInitGood.java b/test/langtools/tools/javac/SuperInit/SuperInitGood.java index 11b845f7d328a..83815f851e3ec 100644 --- a/test/langtools/tools/javac/SuperInit/SuperInitGood.java +++ b/test/langtools/tools/javac/SuperInit/SuperInitGood.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2022, 2024, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2022, 2025, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -24,7 +24,6 @@ * @test * @bug 8194743 * @summary Test valid placements of super()/this() in constructors - * @enablePreview */ import java.util.concurrent.atomic.AtomicReference; diff --git a/test/langtools/tools/javac/diags/examples/CantAssignInitializedBeforeCtorCalled.java b/test/langtools/tools/javac/diags/examples/CantAssignInitializedBeforeCtorCalled.java index 55f5d19451d13..0d19a9a9a12db 100644 --- a/test/langtools/tools/javac/diags/examples/CantAssignInitializedBeforeCtorCalled.java +++ b/test/langtools/tools/javac/diags/examples/CantAssignInitializedBeforeCtorCalled.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2024, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2024, 2025, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -21,10 +21,7 @@ * questions. */ - // key: compiler.note.preview.filename - // key: compiler.note.preview.recompile // key: compiler.err.cant.assign.initialized.before.ctor.called - // options: --enable-preview -source ${jdk.version} class CantAssignInitializedBeforeCtorCalled { int x = 1; diff --git a/test/langtools/tools/javac/diags/examples/FeatureFlexibleConstructors.java b/test/langtools/tools/javac/diags/examples/FeatureFlexibleConstructors.java index 6bdff09e96f67..269e0bda6873a 100644 --- a/test/langtools/tools/javac/diags/examples/FeatureFlexibleConstructors.java +++ b/test/langtools/tools/javac/diags/examples/FeatureFlexibleConstructors.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2024, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2024, 2025, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -22,8 +22,8 @@ */ // key: compiler.misc.feature.flexible.constructors - // key: compiler.warn.preview.feature.use - // options: --enable-preview -source ${jdk.version} -Xlint:preview + // key: compiler.err.feature.not.supported.in.source + // options: --release 24 class FeatureFlexibleConstructors { FeatureFlexibleConstructors() { diff --git a/test/langtools/tools/javac/diags/examples/PreviewFeatureUse.java b/test/langtools/tools/javac/diags/examples/PreviewFeatureUse.java index 799775cf5f8cd..455ddddab866c 100644 --- a/test/langtools/tools/javac/diags/examples/PreviewFeatureUse.java +++ b/test/langtools/tools/javac/diags/examples/PreviewFeatureUse.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2018, 2019, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2025, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -21,14 +21,15 @@ * questions. */ -//key: compiler.warn.preview.feature.use.plural -//key: compiler.misc.feature.var.syntax.in.implicit.lambda +//key: compiler.warn.preview.feature.use +//key: compiler.misc.feature.flexible.constructors //options: -Xlint:preview -XDforcePreview -source ${jdk.version} --enable-preview import java.util.function.Function; class PreviewFeatureUse { - void test() { - Function f = (var s) -> s; + PreviewFeatureUse() { + System.out.println("early init!"); + super(); } } diff --git a/test/langtools/tools/javac/diags/examples/PreviewFeatureUsePlural.java b/test/langtools/tools/javac/diags/examples/PreviewFeatureUsePlural.java new file mode 100644 index 0000000000000..ae6bccecaddd2 --- /dev/null +++ b/test/langtools/tools/javac/diags/examples/PreviewFeatureUsePlural.java @@ -0,0 +1,34 @@ +/* + * Copyright (c) 2018, 2025, Oracle and/or its affiliates. All rights reserved. + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * This code is free software; you can redistribute it and/or modify it + * under the terms of the GNU General Public License version 2 only, as + * published by the Free Software Foundation. + * + * This code is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + * version 2 for more details (a copy is included in the LICENSE file that + * accompanied this code). + * + * You should have received a copy of the GNU General Public License version + * 2 along with this work; if not, write to the Free Software Foundation, + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. + * + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA + * or visit www.oracle.com if you need additional information or have any + * questions. + */ + +//key: compiler.warn.preview.feature.use.plural +//key: compiler.misc.feature.var.syntax.in.implicit.lambda +//options: -Xlint:preview -XDforcePreview -source ${jdk.version} --enable-preview + +import java.util.function.Function; + +class PreviewFeatureUsePlural { + void test() { + Function f = (var s) -> s; + } +} diff --git a/test/langtools/tools/javac/diags/examples/ReturnBeforeSuperclassInit.java b/test/langtools/tools/javac/diags/examples/ReturnBeforeSuperclassInit.java index dc883b59b8f69..033a843062560 100644 --- a/test/langtools/tools/javac/diags/examples/ReturnBeforeSuperclassInit.java +++ b/test/langtools/tools/javac/diags/examples/ReturnBeforeSuperclassInit.java @@ -22,9 +22,6 @@ */ // key: compiler.err.return.before.superclass.initialized -// key: compiler.note.preview.filename -// key: compiler.note.preview.recompile -// options: --enable-preview -source ${jdk.version} class ReturnBeforeSuperclassInit { ReturnBeforeSuperclassInit(boolean maybe) {