diff --git a/make/langtools/src/classes/build/tools/symbolgenerator/CreateSymbols.java b/make/langtools/src/classes/build/tools/symbolgenerator/CreateSymbols.java index fa6d9d836308c..74a817e990b18 100644 --- a/make/langtools/src/classes/build/tools/symbolgenerator/CreateSymbols.java +++ b/make/langtools/src/classes/build/tools/symbolgenerator/CreateSymbols.java @@ -132,6 +132,7 @@ import com.sun.tools.classfile.Module_attribute.RequiresEntry; import com.sun.tools.classfile.NestHost_attribute; import com.sun.tools.classfile.NestMembers_attribute; +import com.sun.tools.classfile.PermittedSubclasses_attribute; import com.sun.tools.classfile.Record_attribute; import com.sun.tools.classfile.Record_attribute.ComponentInfo; import com.sun.tools.classfile.RuntimeAnnotations_attribute; @@ -978,6 +979,16 @@ private void addAttributes(ClassHeaderDescription header, attributes.put(Attribute.Record, new Record_attribute(attributeString, recordComponents)); } + if (header.isSealed) { + int attributeString = addString(constantPool, Attribute.PermittedSubclasses); + int[] subclasses = new int[header.permittedSubclasses.size()]; + int i = 0; + for (String intf : header.permittedSubclasses) { + subclasses[i++] = addClass(constantPool, intf); + } + attributes.put(Attribute.PermittedSubclasses, + new PermittedSubclasses_attribute(attributeString, subclasses)); + } addInnerClassesAttribute(header, constantPool, attributes); } @@ -2229,6 +2240,16 @@ private boolean readAttribute(ClassFile cf, FeatureDescription feature, Attribut } break; } + case Attribute.PermittedSubclasses: { + assert feature instanceof ClassHeaderDescription; + PermittedSubclasses_attribute permittedSubclasses = (PermittedSubclasses_attribute) attr; + ClassHeaderDescription chd = (ClassHeaderDescription) feature; + chd.permittedSubclasses = Arrays.stream(permittedSubclasses.subtypes) + .mapToObj(i -> getClassName(cf, i)) + .collect(Collectors.toList()); + chd.isSealed = true; + break; + } default: throw new IllegalStateException("Unhandled attribute: " + attrName); @@ -3077,6 +3098,8 @@ static class ClassHeaderDescription extends HeaderDescription { List nestMembers; boolean isRecord; List recordComponents; + boolean isSealed; + List permittedSubclasses; @Override public int hashCode() { @@ -3087,6 +3110,8 @@ public int hashCode() { hash = 17 * hash + Objects.hashCode(this.nestMembers); hash = 17 * hash + Objects.hashCode(this.isRecord); hash = 17 * hash + Objects.hashCode(this.recordComponents); + hash = 17 * hash + Objects.hashCode(this.isSealed); + hash = 17 * hash + Objects.hashCode(this.permittedSubclasses); return hash; } @@ -3117,6 +3142,12 @@ public boolean equals(Object obj) { if (!listEquals(this.recordComponents, other.recordComponents)) { return false; } + if (this.isSealed != other.isSealed) { + return false; + } + if (!listEquals(this.permittedSubclasses, other.permittedSubclasses)) { + return false; + } return true; } @@ -3137,6 +3168,9 @@ public void write(Appendable output, String baselineVersion, String version) thr if (isRecord) { output.append(" record true"); } + if (isSealed) { + output.append(" sealed true"); + } writeAttributes(output); output.append("\n"); writeRecordComponents(output, baselineVersion, version); @@ -3163,6 +3197,11 @@ public boolean read(LineBasedReader reader) throws IOException { readRecordComponents(reader); } readInnerClasses(reader); + isSealed = reader.attributes.containsKey("permittedSubclasses"); + if (isSealed) { + String subclassesList = reader.attributes.get("permittedSubclasses"); + permittedSubclasses = deserializeList(subclassesList); + } return true; } diff --git a/src/hotspot/share/classfile/classFileParser.cpp b/src/hotspot/share/classfile/classFileParser.cpp index a0ba49613e2ee..d7136bc84e0bf 100644 --- a/src/hotspot/share/classfile/classFileParser.cpp +++ b/src/hotspot/share/classfile/classFileParser.cpp @@ -3532,12 +3532,6 @@ void ClassFileParser::parse_classfile_bootstrap_methods_attribute(const ClassFil CHECK); } -bool ClassFileParser::supports_sealed_types() { - return _major_version == JVM_CLASSFILE_MAJOR_VERSION && - _minor_version == JAVA_PREVIEW_MINOR_VERSION && - Arguments::enable_preview(); -} - void ClassFileParser::parse_classfile_attributes(const ClassFileStream* const cfs, ConstantPool* cp, ClassFileParser::ClassAnnotationCollector* parsed_annotations, @@ -3794,8 +3788,8 @@ void ClassFileParser::parse_classfile_attributes(const ClassFileStream* const cf parsed_record_attribute = true; record_attribute_start = cfs->current(); record_attribute_length = attribute_length; - } else if (tag == vmSymbols::tag_permitted_subclasses()) { - if (supports_sealed_types()) { + } else if (_major_version >= JAVA_17_VERSION) { + if (tag == vmSymbols::tag_permitted_subclasses()) { if (parsed_permitted_subclasses_attribute) { classfile_parse_error("Multiple PermittedSubclasses attributes in class file %s", CHECK); return; @@ -3810,7 +3804,7 @@ void ClassFileParser::parse_classfile_attributes(const ClassFileStream* const cf permitted_subclasses_attribute_length = attribute_length; } } - // Skip attribute_length for any attribute where major_verson >= JAVA_16_VERSION + // Skip attribute_length for any attribute where major_verson >= JAVA_17_VERSION cfs->skip_u1(attribute_length, CHECK); } else { // Unknown attribute diff --git a/src/hotspot/share/classfile/classFileParser.hpp b/src/hotspot/share/classfile/classFileParser.hpp index ae92008333712..206cd3601e336 100644 --- a/src/hotspot/share/classfile/classFileParser.hpp +++ b/src/hotspot/share/classfile/classFileParser.hpp @@ -333,9 +333,6 @@ class ClassFileParser { const u1* const record_attribute_start, TRAPS); - bool supports_sealed_types(); - bool supports_records(); - void parse_classfile_attributes(const ClassFileStream* const cfs, ConstantPool* cp, ClassAnnotationCollector* parsed_annotations, diff --git a/src/hotspot/share/include/jvm.h b/src/hotspot/share/include/jvm.h index 1be9b82e9eeb8..8476c12aea00b 100644 --- a/src/hotspot/share/include/jvm.h +++ b/src/hotspot/share/include/jvm.h @@ -606,7 +606,7 @@ JVM_GetNestHost(JNIEnv *env, jclass current); JNIEXPORT jobjectArray JNICALL JVM_GetNestMembers(JNIEnv *env, jclass current); -/* Records - since JDK 14 */ +/* Records - since JDK 16 */ JNIEXPORT jboolean JNICALL JVM_IsRecord(JNIEnv *env, jclass cls); @@ -614,7 +614,7 @@ JVM_IsRecord(JNIEnv *env, jclass cls); JNIEXPORT jobjectArray JNICALL JVM_GetRecordComponents(JNIEnv *env, jclass ofClass); -/* Sealed types - since JDK 15 */ +/* Sealed classes - since JDK 17 */ JNIEXPORT jobjectArray JNICALL JVM_GetPermittedSubclasses(JNIEnv *env, jclass current); diff --git a/src/java.base/share/classes/java/lang/Class.java b/src/java.base/share/classes/java/lang/Class.java index 5f80fc6ead386..687de4153dbba 100644 --- a/src/java.base/share/classes/java/lang/Class.java +++ b/src/java.base/share/classes/java/lang/Class.java @@ -4475,9 +4475,8 @@ public Optional describeConstable() { * * @jls 8.1 Class Declarations * @jls 9.1 Interface Declarations - * @since 15 + * @since 17 */ - @jdk.internal.javac.PreviewFeature(feature=jdk.internal.javac.PreviewFeature.Feature.SEALED_CLASSES, reflective=true) @CallerSensitive public Class[] getPermittedSubclasses() { Class[] subClasses; @@ -4524,14 +4523,13 @@ private boolean isDirectSubType(Class c) { * subclasses; {@link #getPermittedSubclasses()} returns a non-null but * possibly empty value for a sealed class or interface. * - * @return {@code true} if and only if this {@code Class} object represents a sealed class or interface. + * @return {@code true} if and only if this {@code Class} object represents + * a sealed class or interface. * * @jls 8.1 Class Declarations * @jls 9.1 Interface Declarations - * @since 15 + * @since 17 */ - @jdk.internal.javac.PreviewFeature(feature=jdk.internal.javac.PreviewFeature.Feature.SEALED_CLASSES, reflective=true) - @SuppressWarnings("preview") public boolean isSealed() { if (isArray() || isPrimitive()) { return false; diff --git a/src/java.base/share/classes/jdk/internal/javac/PreviewFeature.java b/src/java.base/share/classes/jdk/internal/javac/PreviewFeature.java index dfa3435a3f055..6ec5eeae5cab1 100644 --- a/src/java.base/share/classes/jdk/internal/javac/PreviewFeature.java +++ b/src/java.base/share/classes/jdk/internal/javac/PreviewFeature.java @@ -54,6 +54,9 @@ public boolean reflective() default false; public enum Feature { + /* + * This one can only be removed after JDK 17 + */ SEALED_CLASSES, /** * A key for testing. diff --git a/src/jdk.compiler/share/classes/com/sun/source/tree/ClassTree.java b/src/jdk.compiler/share/classes/com/sun/source/tree/ClassTree.java index 463bdf2749827..7e6b50cc08fe9 100644 --- a/src/jdk.compiler/share/classes/com/sun/source/tree/ClassTree.java +++ b/src/jdk.compiler/share/classes/com/sun/source/tree/ClassTree.java @@ -93,10 +93,8 @@ public interface ClassTree extends StatementTree { * * @return the subclasses * - * @since 15 + * @since 17 */ - @jdk.internal.javac.PreviewFeature(feature=jdk.internal.javac.PreviewFeature.Feature.SEALED_CLASSES, - reflective=true) default List getPermitsClause() { return List.of(); } 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 4cf32630daa83..b9efac8113f64 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 @@ -183,8 +183,6 @@ public boolean isEnabled() { */ public boolean isPreview(Feature feature) { return switch (feature) { - case SEALED_CLASSES -> 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' //for those selected features, and 'false' for all the others. @@ -224,9 +222,7 @@ public Error disabledError(JavaFileObject classfile, int majorVersion) { * @return true iff sym has been declared using a preview language feature */ public boolean declaredUsingPreviewFeature(Symbol sym) { - return ((sym.flags() & RECORD) != 0 && isPreview(Feature.RECORDS)) || - ((sym.flags() & SEALED) != 0 && isPreview(Feature.SEALED_CLASSES)) || - ((sym.flags() & NON_SEALED) != 0 && isPreview(Feature.SEALED_CLASSES)); + return false; } /** diff --git a/src/jdk.compiler/share/classes/com/sun/tools/javac/comp/Check.java b/src/jdk.compiler/share/classes/com/sun/tools/javac/comp/Check.java index 227fd07a235e4..ba358abb8eb51 100644 --- a/src/jdk.compiler/share/classes/com/sun/tools/javac/comp/Check.java +++ b/src/jdk.compiler/share/classes/com/sun/tools/javac/comp/Check.java @@ -161,8 +161,7 @@ protected Check(Context context) { deferredLintHandler = DeferredLintHandler.instance(context); allowRecords = Feature.RECORDS.allowedInSource(source); - allowSealed = (!preview.isPreview(Feature.SEALED_CLASSES) || preview.isEnabled()) && - Feature.SEALED_CLASSES.allowedInSource(source); + allowSealed = Feature.SEALED_CLASSES.allowedInSource(source); } /** Character for synthetic names diff --git a/src/jdk.compiler/share/classes/com/sun/tools/javac/jvm/ClassReader.java b/src/jdk.compiler/share/classes/com/sun/tools/javac/jvm/ClassReader.java index 0b0e8c286c9d2..1e7d8d5ecdc12 100644 --- a/src/jdk.compiler/share/classes/com/sun/tools/javac/jvm/ClassReader.java +++ b/src/jdk.compiler/share/classes/com/sun/tools/javac/jvm/ClassReader.java @@ -278,8 +278,7 @@ protected ClassReader(Context context) { preview = Preview.instance(context); allowModules = Feature.MODULES.allowedInSource(source); allowRecords = Feature.RECORDS.allowedInSource(source); - allowSealedTypes = (!preview.isPreview(Feature.SEALED_CLASSES) || preview.isEnabled()) && - Feature.SEALED_CLASSES.allowedInSource(source); + allowSealedTypes = Feature.SEALED_CLASSES.allowedInSource(source); saveParameterNames = options.isSet(PARAMETERS); diff --git a/src/jdk.compiler/share/classes/com/sun/tools/javac/parser/JavacParser.java b/src/jdk.compiler/share/classes/com/sun/tools/javac/parser/JavacParser.java index 4c6d56e871397..f5a97d0632e53 100644 --- a/src/jdk.compiler/share/classes/com/sun/tools/javac/parser/JavacParser.java +++ b/src/jdk.compiler/share/classes/com/sun/tools/javac/parser/JavacParser.java @@ -186,8 +186,7 @@ protected JavacParser(ParserFactory fac, this.allowYieldStatement = (!preview.isPreview(Feature.SWITCH_EXPRESSION) || preview.isEnabled()) && Feature.SWITCH_EXPRESSION.allowedInSource(source); this.allowRecords = Feature.RECORDS.allowedInSource(source); - this.allowSealedTypes = (!preview.isPreview(Feature.SEALED_CLASSES) || preview.isEnabled()) && - Feature.SEALED_CLASSES.allowedInSource(source); + this.allowSealedTypes = Feature.SEALED_CLASSES.allowedInSource(source); } protected AbstractEndPosTable newEndPosTable(boolean keepEndPositions) { diff --git a/test/hotspot/jtreg/runtime/modules/SealedInterfaceModuleTest.java b/test/hotspot/jtreg/runtime/modules/SealedInterfaceModuleTest.java index 9c1ad582bca12..5df0594860e77 100644 --- a/test/hotspot/jtreg/runtime/modules/SealedInterfaceModuleTest.java +++ b/test/hotspot/jtreg/runtime/modules/SealedInterfaceModuleTest.java @@ -27,11 +27,11 @@ * @modules java.base/jdk.internal.misc * @library /test/lib .. * @compile sealedP1/SuperInterface.jcod - * @compile --enable-preview --source ${jdk.version} sealedP1/C1.java sealedP2/C2.java sealedP3/C3.java + * @compile sealedP1/C1.java sealedP2/C2.java sealedP3/C3.java * @build sun.hotspot.WhiteBox * @compile/module=java.base java/lang/ModuleHelper.java * @run driver jdk.test.lib.helpers.ClassFileInstaller sun.hotspot.WhiteBox - * @run main/othervm -Xbootclasspath/a:. --enable-preview -XX:+UnlockDiagnosticVMOptions -XX:+WhiteBoxAPI SealedInterfaceModuleTest + * @run main/othervm -Xbootclasspath/a:. -XX:+UnlockDiagnosticVMOptions -XX:+WhiteBoxAPI SealedInterfaceModuleTest */ public class SealedInterfaceModuleTest { diff --git a/test/hotspot/jtreg/runtime/modules/SealedModuleTest.java b/test/hotspot/jtreg/runtime/modules/SealedModuleTest.java index 042a3abaf61cd..8e38f444b95dc 100644 --- a/test/hotspot/jtreg/runtime/modules/SealedModuleTest.java +++ b/test/hotspot/jtreg/runtime/modules/SealedModuleTest.java @@ -27,11 +27,11 @@ * @modules java.base/jdk.internal.misc * @library /test/lib .. * @compile sealedP1/SuperClass.jcod - * @compile --enable-preview --source ${jdk.version} sealedP1/C1.java sealedP2/C2.java sealedP3/C3.java + * @compile sealedP1/C1.java sealedP2/C2.java sealedP3/C3.java * @build sun.hotspot.WhiteBox * @compile/module=java.base java/lang/ModuleHelper.java * @run driver jdk.test.lib.helpers.ClassFileInstaller sun.hotspot.WhiteBox - * @run main/othervm -Xbootclasspath/a:. --enable-preview -XX:+UnlockDiagnosticVMOptions -XX:+WhiteBoxAPI SealedModuleTest + * @run main/othervm -Xbootclasspath/a:. -XX:+UnlockDiagnosticVMOptions -XX:+WhiteBoxAPI SealedModuleTest */ public class SealedModuleTest { diff --git a/test/hotspot/jtreg/runtime/modules/sealedP1/SuperClass.jcod b/test/hotspot/jtreg/runtime/modules/sealedP1/SuperClass.jcod index 22f707550e28d..d19cc60982600 100644 --- a/test/hotspot/jtreg/runtime/modules/sealedP1/SuperClass.jcod +++ b/test/hotspot/jtreg/runtime/modules/sealedP1/SuperClass.jcod @@ -1,5 +1,5 @@ /* - * Copyright (c) 2020, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2020, 2021, 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 @@ -32,7 +32,7 @@ class sealedP1/SuperClass { 0xCAFEBABE; - 65535; // minor version + 0; // minor version 61; // version [20] { // Constant Pool ; // first element is empty diff --git a/test/hotspot/jtreg/runtime/modules/sealedP1/SuperInterface.jcod b/test/hotspot/jtreg/runtime/modules/sealedP1/SuperInterface.jcod index 7c626e3925af9..433e228833bad 100644 --- a/test/hotspot/jtreg/runtime/modules/sealedP1/SuperInterface.jcod +++ b/test/hotspot/jtreg/runtime/modules/sealedP1/SuperInterface.jcod @@ -1,5 +1,5 @@ /* - * Copyright (c) 2020, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2020, 2021, 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 @@ -32,7 +32,7 @@ // class sealedP1/SuperInterface { 0xCAFEBABE; - 65535; // minor version + 0; // minor version 61; // version [14] { // Constant Pool ; // first element is empty diff --git a/test/hotspot/jtreg/runtime/sealedClasses/AbstractSealedTest.java b/test/hotspot/jtreg/runtime/sealedClasses/AbstractSealedTest.java deleted file mode 100644 index ee17397d564a2..0000000000000 --- a/test/hotspot/jtreg/runtime/sealedClasses/AbstractSealedTest.java +++ /dev/null @@ -1,45 +0,0 @@ -/* - * Copyright (c) 2020, 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. - */ - -/* - * @test - * @bug 8225056 - * @compile --enable-preview -source ${jdk.version} AbstractSealedTest.java - * @run main/othervm --enable-preview AbstractSealedTest - */ - -// Test that a sealed class can be abstract -public class AbstractSealedTest { - - abstract sealed class AbstractShape permits Circle { - abstract void draw(); - } - - final class Circle extends AbstractShape { - void draw() {} - } - - Circle circle = new Circle(); - - public static void main(String... args) { } -} diff --git a/test/hotspot/jtreg/runtime/sealedClasses/GetPermittedSubclasses.jcod b/test/hotspot/jtreg/runtime/sealedClasses/GetPermittedSubclasses.jcod index 06fda7e9d32a2..62422ef90dc30 100644 --- a/test/hotspot/jtreg/runtime/sealedClasses/GetPermittedSubclasses.jcod +++ b/test/hotspot/jtreg/runtime/sealedClasses/GetPermittedSubclasses.jcod @@ -1,5 +1,5 @@ /* - * Copyright (c) 2020, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2020, 2021, 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 @@ -28,7 +28,7 @@ // class NoLoadSubclasses { 0xCAFEBABE; - 65535; // minor version + 0; // minor version 61; // version [18] { // Constant Pool ; // first element is empty @@ -167,7 +167,7 @@ class ExistingClassFile { // this does not cause an exception to get thrown. class NoSubclasses { 0xCAFEBABE; - 65535; // minor version + 0; // minor version 61; // version [14] { // Constant Pool ; // first element is empty @@ -238,7 +238,7 @@ class NoSubclasses { // PermittedSubtypes attribute cannot be subclass-ed. class SubClass { 0xCAFEBABE; - 65535; // minor version + 0; // minor version 61; // version [13] { // Constant Pool ; // first element is empty @@ -384,7 +384,7 @@ class OldClassFile { // should throw ClassFormatError. class BadPermittedAttr { 0xCAFEBABE; - 65535; // minor version + 0; // minor version 61; // version [18] { // Constant Pool ; // first element is empty @@ -462,7 +462,7 @@ class BadPermittedAttr { // class SealedButFinal { 0xCAFEBABE; - 65535; // minor version + 0; // minor version 61; // version [18] { // Constant Pool ; // first element is empty @@ -540,7 +540,7 @@ class SealedButFinal { // class BadPermittedSubclassEntry { 0xCAFEBABE; - 65535; // minor version + 0; // minor version 61; // version [18] { // Constant Pool ; // first element is empty @@ -617,7 +617,7 @@ class BadPermittedSubclassEntry { // class EmptyPermittedSubclassEntry { 0xCAFEBABE; - 65535; // minor version + 0; // minor version 61; // version [18] { // Constant Pool ; // first element is empty diff --git a/test/hotspot/jtreg/runtime/sealedClasses/GetPermittedSubclassesTest.java b/test/hotspot/jtreg/runtime/sealedClasses/GetPermittedSubclassesTest.java index d77de99cf4025..4beacfffe26b7 100644 --- a/test/hotspot/jtreg/runtime/sealedClasses/GetPermittedSubclassesTest.java +++ b/test/hotspot/jtreg/runtime/sealedClasses/GetPermittedSubclassesTest.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2020, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2020, 2021, 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 @@ -25,10 +25,9 @@ * @test * @bug 8225056 * @compile GetPermittedSubclasses.jcod - * @compile --enable-preview -source ${jdk.version} noSubclass/BaseC.java noSubclass/BaseI.java noSubclass/Impl1.java - * @compile --enable-preview -source ${jdk.version} noSubclass/Impl2.java - * @compile --enable-preview -source ${jdk.version} GetPermittedSubclassesTest.java - * @run main/othervm --enable-preview GetPermittedSubclassesTest + * @compile noSubclass/BaseC.java noSubclass/BaseI.java noSubclass/Impl1.java + * @compile noSubclass/Impl2.java + * @run main GetPermittedSubclassesTest */ import java.util.ArrayList; diff --git a/test/hotspot/jtreg/runtime/sealedClasses/OverrideSealedTest.java b/test/hotspot/jtreg/runtime/sealedClasses/OverrideSealedTest.java index 5c70e3ef73783..1e4e5697cf9a7 100644 --- a/test/hotspot/jtreg/runtime/sealedClasses/OverrideSealedTest.java +++ b/test/hotspot/jtreg/runtime/sealedClasses/OverrideSealedTest.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2020, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2020, 2021, 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,8 +24,6 @@ /* * @test * @bug 8225056 - * @compile --enable-preview -source ${jdk.version} OverrideSealedTest.java - * @run main/othervm --enable-preview OverrideSealedTest */ // Test that a method in a sealed class or interface can be overridden. diff --git a/test/hotspot/jtreg/runtime/sealedClasses/Pkg/SealedInterface.jcod b/test/hotspot/jtreg/runtime/sealedClasses/Pkg/SealedInterface.jcod index 137f0dfad5187..2a26b9a5568ec 100644 --- a/test/hotspot/jtreg/runtime/sealedClasses/Pkg/SealedInterface.jcod +++ b/test/hotspot/jtreg/runtime/sealedClasses/Pkg/SealedInterface.jcod @@ -1,5 +1,5 @@ /* - * Copyright (c) 2020, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2020, 2021, 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 @@ -30,7 +30,7 @@ class Pkg/SealedInterface { 0xCAFEBABE; - 65535; // minor version + 0; // minor version 61; // version [14] { // Constant Pool ; // first element is empty diff --git a/test/hotspot/jtreg/runtime/sealedClasses/RedefinePermittedSubclass.java b/test/hotspot/jtreg/runtime/sealedClasses/RedefinePermittedSubclass.java index 147c296453566..e2cc20783b27e 100644 --- a/test/hotspot/jtreg/runtime/sealedClasses/RedefinePermittedSubclass.java +++ b/test/hotspot/jtreg/runtime/sealedClasses/RedefinePermittedSubclass.java @@ -30,9 +30,9 @@ * @modules java.base/jdk.internal.misc * @modules java.instrument * @requires vm.jvmti - * @compile --enable-preview -source ${jdk.version} RedefinePermittedSubclass.java - * @run main/othervm --enable-preview RedefinePermittedSubclass buildagent - * @run main/othervm/timeout=6000 --enable-preview RedefinePermittedSubclass runtest + * @compile RedefinePermittedSubclass.java + * @run main/othervm RedefinePermittedSubclass buildagent + * @run main/othervm/timeout=6000 RedefinePermittedSubclass runtest */ import java.io.FileNotFoundException; @@ -124,8 +124,7 @@ public static void main(String argv[]) throws Exception { } if (argv.length == 1 && argv[0].equals("runtest")) { String[] javaArgs1 = { "-XX:MetaspaceSize=12m", "-XX:MaxMetaspaceSize=12m", - "-javaagent:redefineagent.jar", "--enable-preview", - "RedefinePermittedSubclass"}; + "-javaagent:redefineagent.jar", "RedefinePermittedSubclass"}; ProcessBuilder pb = ProcessTools.createJavaProcessBuilder(javaArgs1); OutputAnalyzer output = new OutputAnalyzer(pb.start()); output.shouldNotContain("processing of -javaagent failed"); diff --git a/test/hotspot/jtreg/runtime/sealedClasses/RedefineSealedClass.java b/test/hotspot/jtreg/runtime/sealedClasses/RedefineSealedClass.java index 418071032d242..ccea8aa9eeccd 100644 --- a/test/hotspot/jtreg/runtime/sealedClasses/RedefineSealedClass.java +++ b/test/hotspot/jtreg/runtime/sealedClasses/RedefineSealedClass.java @@ -29,9 +29,9 @@ * @modules java.base/jdk.internal.misc * @modules java.instrument * @requires vm.jvmti - * @compile --enable-preview -source ${jdk.version} RedefineSealedClass.java - * @run main/othervm --enable-preview RedefineSealedClass buildagent - * @run main/othervm/timeout=6000 --enable-preview RedefineSealedClass runtest + * @compile RedefineSealedClass.java + * @run main/othervm RedefineSealedClass buildagent + * @run main/othervm/timeout=6000 RedefineSealedClass runtest */ import java.io.FileNotFoundException; @@ -106,8 +106,7 @@ public static void main(String argv[]) throws Exception { } if (argv.length == 1 && argv[0].equals("runtest")) { String[] javaArgs1 = { "-XX:MetaspaceSize=12m", "-XX:MaxMetaspaceSize=12m", - "-javaagent:redefineagent.jar", "--enable-preview", - "RedefineSealedClass"}; + "-javaagent:redefineagent.jar", "RedefineSealedClass"}; ProcessBuilder pb = ProcessTools.createJavaProcessBuilder(javaArgs1); OutputAnalyzer output = new OutputAnalyzer(pb.start()); output.shouldNotContain("processing of -javaagent failed"); diff --git a/test/hotspot/jtreg/runtime/sealedClasses/SealedTest.java b/test/hotspot/jtreg/runtime/sealedClasses/SealedTest.java deleted file mode 100644 index 01dab6d39c57b..0000000000000 --- a/test/hotspot/jtreg/runtime/sealedClasses/SealedTest.java +++ /dev/null @@ -1,49 +0,0 @@ -/* - * Copyright (c) 2020, 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. - */ - -/* - * @test - * @bug 8225056 - * @compile --enable-preview -source ${jdk.version} SealedTest.java - * @run main/othervm --enable-preview SealedTest - */ - -public class SealedTest { - - sealed class Sealed1 permits Sub1 {} - - final class Sub1 extends Sealed1 {} - - sealed interface SealedI1 permits Sub2 {} - - final class Sub2 extends Sealed2 implements SealedI1 {} - - sealed class Sealed2 permits Sub2 {} - - Sub1 sub1 = new Sub1(); - Sub2 sub2 = new Sub2(); - - public static void main(String... args) { - System.out.println("Basic testing of sealed types"); - } -} diff --git a/test/hotspot/jtreg/runtime/sealedClasses/SealedUnnamedModuleIntfTest.java b/test/hotspot/jtreg/runtime/sealedClasses/SealedUnnamedModuleIntfTest.java index f5757894b953c..05adb3d7d4154 100644 --- a/test/hotspot/jtreg/runtime/sealedClasses/SealedUnnamedModuleIntfTest.java +++ b/test/hotspot/jtreg/runtime/sealedClasses/SealedUnnamedModuleIntfTest.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2020, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2020, 2021, 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 @@ -25,8 +25,8 @@ * @test * @bug 8225056 * @compile Pkg/SealedInterface.jcod Pkg/NotPermitted.jcod - * @compile --enable-preview -source ${jdk.version} Pkg/Permitted.java otherPkg/WrongPackage.java otherPkg/WrongPackageNotPublic.java - * @run main/othervm --enable-preview SealedUnnamedModuleIntfTest + * @compile Pkg/Permitted.java otherPkg/WrongPackage.java otherPkg/WrongPackageNotPublic.java + * @run main SealedUnnamedModuleIntfTest */ public class SealedUnnamedModuleIntfTest { diff --git a/test/hotspot/jtreg/runtime/sealedClasses/SealedUnnamedModuleTest.java b/test/hotspot/jtreg/runtime/sealedClasses/SealedUnnamedModuleTest.java index f74b4713dfabe..020d975dfed58 100644 --- a/test/hotspot/jtreg/runtime/sealedClasses/SealedUnnamedModuleTest.java +++ b/test/hotspot/jtreg/runtime/sealedClasses/SealedUnnamedModuleTest.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2020, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2020, 2021, 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 @@ -25,8 +25,8 @@ * @test * @bug 8225056 * @compile planets/OuterPlanets.jcod planets/Mars.jcod - * @compile --enable-preview -source ${jdk.version} planets/Neptune.java asteroids/Pluto.java asteroids/Charon.java - * @run main/othervm --enable-preview SealedUnnamedModuleTest + * @compile planets/Neptune.java asteroids/Pluto.java asteroids/Charon.java + * @run main SealedUnnamedModuleTest */ public class SealedUnnamedModuleTest { diff --git a/test/hotspot/jtreg/runtime/sealedClasses/planets/OuterPlanets.jcod b/test/hotspot/jtreg/runtime/sealedClasses/planets/OuterPlanets.jcod index d5044ccba891b..91cd44465304e 100644 --- a/test/hotspot/jtreg/runtime/sealedClasses/planets/OuterPlanets.jcod +++ b/test/hotspot/jtreg/runtime/sealedClasses/planets/OuterPlanets.jcod @@ -1,5 +1,5 @@ /* - * Copyright (c) 2019, 2020, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2019, 2021, 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 @@ -27,7 +27,7 @@ class planets/OuterPlanets { 0xCAFEBABE; - 65535; // minor version + 0; // minor version 61; // version [20] { // Constant Pool ; // first element is empty diff --git a/test/jdk/java/lang/instrument/RedefinePermittedSubclassesAttr/TestPermittedSubclassesAttr.java b/test/jdk/java/lang/instrument/RedefinePermittedSubclassesAttr/TestPermittedSubclassesAttr.java index 346cce55bb7aa..efe2bc2e37104 100644 --- a/test/jdk/java/lang/instrument/RedefinePermittedSubclassesAttr/TestPermittedSubclassesAttr.java +++ b/test/jdk/java/lang/instrument/RedefinePermittedSubclassesAttr/TestPermittedSubclassesAttr.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2020, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2020, 2021, 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 @@ -34,15 +34,15 @@ * java.instrument * @compile ../NamedBuffer.java * @run main RedefineClassHelper - * @compile --enable-preview --source ${jdk.version} Host/Host.java ClassOne.java ClassTwo.java ClassThree.java ClassFour.java - * @compile --enable-preview --source ${jdk.version} TestPermittedSubclassesAttr.java - * @run main/othervm -javaagent:redefineagent.jar --enable-preview -Xlog:redefine+class+sealed=trace TestPermittedSubclassesAttr Host - * @compile --enable-preview --source ${jdk.version} HostA/Host.java - * @run main/othervm -javaagent:redefineagent.jar --enable-preview -Xlog:redefine+class+sealed=trace TestPermittedSubclassesAttr HostA - * @compile --enable-preview --source ${jdk.version} HostAB/Host.java - * @run main/othervm -javaagent:redefineagent.jar --enable-preview -Xlog:redefine+class+sealed=trace TestPermittedSubclassesAttr HostAB - * @compile --enable-preview --source ${jdk.version} HostABC/Host.java - * @run main/othervm -javaagent:redefineagent.jar --enable-preview -Xlog:redefine+class+sealed=trace TestPermittedSubclassesAttr HostABC + * @compile Host/Host.java ClassOne.java ClassTwo.java ClassThree.java ClassFour.java + * @compile TestPermittedSubclassesAttr.java + * @run main/othervm -javaagent:redefineagent.jar -Xlog:redefine+class+sealed=trace TestPermittedSubclassesAttr Host + * @compile HostA/Host.java + * @run main/othervm -javaagent:redefineagent.jar -Xlog:redefine+class+sealed=trace TestPermittedSubclassesAttr HostA + * @compile HostAB/Host.java + * @run main/othervm -javaagent:redefineagent.jar -Xlog:redefine+class+sealed=trace TestPermittedSubclassesAttr HostAB + * @compile HostABC/Host.java + * @run main/othervm -javaagent:redefineagent.jar -Xlog:redefine+class+sealed=trace TestPermittedSubclassesAttr HostABC */ /* Test Description @@ -139,7 +139,6 @@ public class TestPermittedSubclassesAttr { static final String SRC = System.getProperty("test.src"); static final String DEST = System.getProperty("test.classes"); static final boolean VERBOSE = Boolean.getBoolean("verbose"); - private static final String VERSION = Integer.toString(Runtime.version().feature()); public static void main(String[] args) throws Throwable { String origin = args[0]; @@ -266,8 +265,6 @@ static void compile(String dir) throws Throwable { CompilerUtils.compile(src.toPath(), dst.toPath(), false /* don't recurse */, - "-classpath", DEST, - "--enable-preview", - "--source", VERSION); + "-classpath", DEST); } } diff --git a/test/langtools/tools/javac/diags/examples.not-yet.txt b/test/langtools/tools/javac/diags/examples.not-yet.txt index a3ff27842a0e1..f257b7df8e09d 100644 --- a/test/langtools/tools/javac/diags/examples.not-yet.txt +++ b/test/langtools/tools/javac/diags/examples.not-yet.txt @@ -141,6 +141,9 @@ compiler.warn.preview.feature.use.classfile # preview feature suppor compiler.note.preview.plural.additional # preview feature support: diag test causes intermittent failures (see JDK-8201498) compiler.misc.bad.intersection.target.for.functional.expr # currently not generated, should be removed? compiler.misc.not.an.intf.component +compiler.warn.declared.using.preview # after making sealed classes a final feature there is no other + # preview feature but we should keep this key for future use just + # in case # The following module-related messages will have to stay on the not-yet list for various reasons: compiler.warn.locn.unknown.file.on.module.path # Never issued ATM (short circuited with an if (false)) diff --git a/test/langtools/tools/javac/diags/examples/AnonymousCantInheritFromSealed.java b/test/langtools/tools/javac/diags/examples/AnonymousCantInheritFromSealed.java index 7566258332059..5033e66af0052 100644 --- a/test/langtools/tools/javac/diags/examples/AnonymousCantInheritFromSealed.java +++ b/test/langtools/tools/javac/diags/examples/AnonymousCantInheritFromSealed.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2020, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2020, 2021, 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 @@ -23,10 +23,7 @@ // key: compiler.err.local.classes.cant.extend.sealed // key: compiler.err.sealed.class.must.have.subclasses -// key: compiler.note.preview.filename -// key: compiler.note.preview.recompile // key: compiler.misc.anonymous -// options: --enable-preview -source ${jdk.version} class Main { void m() { diff --git a/test/langtools/tools/javac/diags/examples/CantExtendSealedInAnotherModule/CantExtendSealedInAnotherModule.java b/test/langtools/tools/javac/diags/examples/CantExtendSealedInAnotherModule/CantExtendSealedInAnotherModule.java index 2ff3575c21d91..7c3e00cfbaa5c 100644 --- a/test/langtools/tools/javac/diags/examples/CantExtendSealedInAnotherModule/CantExtendSealedInAnotherModule.java +++ b/test/langtools/tools/javac/diags/examples/CantExtendSealedInAnotherModule/CantExtendSealedInAnotherModule.java @@ -22,6 +22,4 @@ */ // key: compiler.err.class.in.module.cant.extend.sealed.in.diff.module -// key: compiler.note.preview.plural -// key: compiler.note.preview.recompile -// options: --add-reads mSealed=mSub --enable-preview -source ${jdk.version} +// options: --add-reads mSealed=mSub diff --git a/test/langtools/tools/javac/diags/examples/CantExtendSealedInAnotherPkg/CantExtendSealedInAnotherPkg.java b/test/langtools/tools/javac/diags/examples/CantExtendSealedInAnotherPkg/CantExtendSealedInAnotherPkg.java index c421689fc3226..474ac8ce9a17c 100644 --- a/test/langtools/tools/javac/diags/examples/CantExtendSealedInAnotherPkg/CantExtendSealedInAnotherPkg.java +++ b/test/langtools/tools/javac/diags/examples/CantExtendSealedInAnotherPkg/CantExtendSealedInAnotherPkg.java @@ -22,6 +22,3 @@ */ // key: compiler.err.class.in.unnamed.module.cant.extend.sealed.in.diff.package -// key: compiler.note.preview.plural -// key: compiler.note.preview.recompile -// options: --enable-preview -source ${jdk.version} diff --git a/test/langtools/tools/javac/diags/examples/CantInheritFromSealed.java b/test/langtools/tools/javac/diags/examples/CantInheritFromSealed.java index 00f0aa865651c..ddb78b99147c8 100644 --- a/test/langtools/tools/javac/diags/examples/CantInheritFromSealed.java +++ b/test/langtools/tools/javac/diags/examples/CantInheritFromSealed.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2017, 2020, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2017, 2021, 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 @@ -23,9 +23,6 @@ // key: compiler.err.cant.inherit.from.sealed // key: compiler.err.non.sealed.sealed.or.final.expected -// key: compiler.note.preview.filename -// key: compiler.note.preview.recompile -// options: --enable-preview -source ${jdk.version} sealed interface SealedInterface permits Sub1 { void m(); diff --git a/test/langtools/tools/javac/diags/examples/CantInheritFromSealed2.java b/test/langtools/tools/javac/diags/examples/CantInheritFromSealed2.java index 418ff658b4093..c0bad03f3c88f 100644 --- a/test/langtools/tools/javac/diags/examples/CantInheritFromSealed2.java +++ b/test/langtools/tools/javac/diags/examples/CantInheritFromSealed2.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2017, 2020, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2017, 2021, 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,9 +22,6 @@ */ // key: compiler.err.non.sealed.or.sealed.expected -// key: compiler.note.preview.filename -// key: compiler.note.preview.recompile -// options: --enable-preview -source ${jdk.version} sealed interface SealedInterface permits Sub1 { void m(); diff --git a/test/langtools/tools/javac/diags/examples/DuplicateTypeInPermits.java b/test/langtools/tools/javac/diags/examples/DuplicateTypeInPermits.java index 7a656cf232bf0..a0408b9af6412 100644 --- a/test/langtools/tools/javac/diags/examples/DuplicateTypeInPermits.java +++ b/test/langtools/tools/javac/diags/examples/DuplicateTypeInPermits.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2017, 2020, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2017, 2021, 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 @@ -23,9 +23,6 @@ // key: compiler.err.invalid.permits.clause // key: compiler.misc.is.duplicated -// key: compiler.note.preview.filename -// key: compiler.note.preview.recompile -// options: --enable-preview -source ${jdk.version} sealed class Sealed permits Sub, Sub {} diff --git a/test/langtools/tools/javac/diags/examples/LocalCantInheritFromSealed.java b/test/langtools/tools/javac/diags/examples/LocalCantInheritFromSealed.java index 85d212c975e09..d5718aed6df10 100644 --- a/test/langtools/tools/javac/diags/examples/LocalCantInheritFromSealed.java +++ b/test/langtools/tools/javac/diags/examples/LocalCantInheritFromSealed.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2017, 2020, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2017, 2021, 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 @@ -23,10 +23,7 @@ // key: compiler.err.local.classes.cant.extend.sealed // key: compiler.err.sealed.class.must.have.subclasses -// key: compiler.note.preview.filename -// key: compiler.note.preview.recompile // key: compiler.misc.local -// options: --enable-preview -source ${jdk.version} sealed class C { void m() { diff --git a/test/langtools/tools/javac/diags/examples/NonSealedWithNoSealedSuper.java b/test/langtools/tools/javac/diags/examples/NonSealedWithNoSealedSuper.java index d5584985b696f..7b2c3951791f7 100644 --- a/test/langtools/tools/javac/diags/examples/NonSealedWithNoSealedSuper.java +++ b/test/langtools/tools/javac/diags/examples/NonSealedWithNoSealedSuper.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2017, 2020, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2017, 2021, 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,9 +22,6 @@ */ // key: compiler.err.non.sealed.with.no.sealed.supertype -// key: compiler.note.preview.filename -// key: compiler.note.preview.recompile -// options: --enable-preview -source ${jdk.version} class C {} diff --git a/test/langtools/tools/javac/diags/examples/PermitsCantListDeclaringClass.java b/test/langtools/tools/javac/diags/examples/PermitsCantListDeclaringClass.java index 20ba847245a63..39709b748b757 100644 --- a/test/langtools/tools/javac/diags/examples/PermitsCantListDeclaringClass.java +++ b/test/langtools/tools/javac/diags/examples/PermitsCantListDeclaringClass.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2020, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2020, 2021, 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 @@ -23,8 +23,5 @@ // key: compiler.err.invalid.permits.clause // key: compiler.misc.must.not.be.same.class -// key: compiler.note.preview.filename -// key: compiler.note.preview.recompile -// options: --enable-preview -source ${jdk.version} sealed class C permits C {} diff --git a/test/langtools/tools/javac/diags/examples/PermitsCantListSuperType.java b/test/langtools/tools/javac/diags/examples/PermitsCantListSuperType.java index 7519ba74009ea..f975668b49145 100644 --- a/test/langtools/tools/javac/diags/examples/PermitsCantListSuperType.java +++ b/test/langtools/tools/javac/diags/examples/PermitsCantListSuperType.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2020, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2020, 2021, 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 @@ -23,9 +23,6 @@ // key: compiler.err.invalid.permits.clause // key: compiler.misc.must.not.be.supertype -// key: compiler.note.preview.filename -// key: compiler.note.preview.recompile -// options: --enable-preview -source ${jdk.version} interface I {} diff --git a/test/langtools/tools/javac/diags/examples/PermitsInNoSealedClass.java b/test/langtools/tools/javac/diags/examples/PermitsInNoSealedClass.java index a941b7f919966..74472dae8c9cb 100644 --- a/test/langtools/tools/javac/diags/examples/PermitsInNoSealedClass.java +++ b/test/langtools/tools/javac/diags/examples/PermitsInNoSealedClass.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2017, 2020, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2017, 2021, 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 @@ -23,9 +23,6 @@ // key: compiler.err.invalid.permits.clause // key: compiler.misc.class.is.not.sealed -// key: compiler.note.preview.filename -// key: compiler.note.preview.recompile -// options: --enable-preview -source ${jdk.version} class C permits Sub {} diff --git a/test/langtools/tools/javac/diags/examples/SealedMustHaveSubtypes.java b/test/langtools/tools/javac/diags/examples/SealedMustHaveSubtypes.java index c124188ee5abe..4c1d7cb3ff489 100644 --- a/test/langtools/tools/javac/diags/examples/SealedMustHaveSubtypes.java +++ b/test/langtools/tools/javac/diags/examples/SealedMustHaveSubtypes.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2017, 2020, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2017, 2021, 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,5 @@ */ // key: compiler.err.sealed.class.must.have.subclasses -// key: compiler.note.preview.filename -// key: compiler.note.preview.recompile -// options: --enable-preview -source ${jdk.version} sealed class Sealed {} diff --git a/test/langtools/tools/javac/diags/examples/SealedNotAllowedInLocalClass.java b/test/langtools/tools/javac/diags/examples/SealedNotAllowedInLocalClass.java index 573b41acb3cbd..00d32e0c3b4bc 100644 --- a/test/langtools/tools/javac/diags/examples/SealedNotAllowedInLocalClass.java +++ b/test/langtools/tools/javac/diags/examples/SealedNotAllowedInLocalClass.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2017, 2020, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2017, 2021, 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,9 +22,6 @@ */ // key: compiler.err.sealed.or.non.sealed.local.classes.not.allowed -// key: compiler.note.preview.filename -// key: compiler.note.preview.recompile -// options: --enable-preview -source ${jdk.version} class Outer { void m() { diff --git a/test/langtools/tools/javac/diags/examples/SealedTypes.java b/test/langtools/tools/javac/diags/examples/SealedTypes.java index bcf32afd817de..85aca18b2afa1 100644 --- a/test/langtools/tools/javac/diags/examples/SealedTypes.java +++ b/test/langtools/tools/javac/diags/examples/SealedTypes.java @@ -22,9 +22,9 @@ */ // key: compiler.misc.feature.sealed.classes -// key: compiler.warn.preview.feature.use.plural -// key: compiler.warn.declared.using.preview -// options: --enable-preview -source ${jdk.version} -Xlint:preview +// key: compiler.err.feature.not.supported.in.source.plural +// key: compiler.warn.source.no.system.modules.path +// options: -source 16 sealed class Sealed {} diff --git a/test/langtools/tools/javac/diags/examples/SubtypeDoesntExtendSealed.java b/test/langtools/tools/javac/diags/examples/SubtypeDoesntExtendSealed.java index 507e6aa765c62..db9de3d175baa 100644 --- a/test/langtools/tools/javac/diags/examples/SubtypeDoesntExtendSealed.java +++ b/test/langtools/tools/javac/diags/examples/SubtypeDoesntExtendSealed.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2017, 2020, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2017, 2021, 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 @@ -23,9 +23,6 @@ // key: compiler.err.invalid.permits.clause // key: compiler.misc.doesnt.extend.sealed -// key: compiler.note.preview.filename -// key: compiler.note.preview.recompile -// options: --enable-preview -source ${jdk.version} sealed class Sealed permits Sub {} diff --git a/test/langtools/tools/javac/diags/examples/TypeVarInPermits.java b/test/langtools/tools/javac/diags/examples/TypeVarInPermits.java index 904f2e3ffe41f..a5fd5c5c6d2ae 100644 --- a/test/langtools/tools/javac/diags/examples/TypeVarInPermits.java +++ b/test/langtools/tools/javac/diags/examples/TypeVarInPermits.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2017, 2020, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2017, 2021, 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 @@ -23,9 +23,6 @@ // key: compiler.err.invalid.permits.clause // key: compiler.misc.is.a.type.variable -// key: compiler.note.preview.filename -// key: compiler.note.preview.recompile -// options: --enable-preview -source ${jdk.version} class Outer { sealed class Sealed permits T {} diff --git a/test/langtools/tools/javac/preview/DeclaredUsingPreview-class.out b/test/langtools/tools/javac/preview/DeclaredUsingPreview-class.out deleted file mode 100644 index cb6f33ab9aad6..0000000000000 --- a/test/langtools/tools/javac/preview/DeclaredUsingPreview-class.out +++ /dev/null @@ -1,5 +0,0 @@ -- compiler.warn.preview.feature.use.classfile: DeclaredUsingPreviewDeclarations.class, 17 -- compiler.warn.preview.feature.use.classfile: DeclaredUsingPreviewDeclarations$C.class, 17 -- compiler.warn.preview.feature.use.classfile: DeclaredUsingPreviewDeclarations$C2.class, 17 -DeclaredUsingPreview.java:9:37: compiler.warn.declared.using.preview: kindname.class, DeclaredUsingPreviewDeclarations.C -4 warnings diff --git a/test/langtools/tools/javac/preview/DeclaredUsingPreview-source.out b/test/langtools/tools/javac/preview/DeclaredUsingPreview-source.out deleted file mode 100644 index 3630a9e0ac53c..0000000000000 --- a/test/langtools/tools/javac/preview/DeclaredUsingPreview-source.out +++ /dev/null @@ -1,7 +0,0 @@ -DeclaredUsingPreviewDeclarations.java:3:5: compiler.warn.preview.feature.use.plural: (compiler.misc.feature.sealed.classes) -DeclaredUsingPreviewDeclarations.java:3:5: compiler.warn.preview.feature.use.plural: (compiler.misc.feature.sealed.classes) -DeclaredUsingPreviewDeclarations.java:4:5: compiler.warn.preview.feature.use.plural: (compiler.misc.feature.sealed.classes) -DeclaredUsingPreview.java:9:37: compiler.warn.declared.using.preview: kindname.class, DeclaredUsingPreviewDeclarations.C -DeclaredUsingPreview.java:10:37: compiler.warn.declared.using.preview: kindname.class, DeclaredUsingPreviewDeclarations.C2 -DeclaredUsingPreviewDeclarations.java:4:33: compiler.warn.declared.using.preview: kindname.class, DeclaredUsingPreviewDeclarations.C -6 warnings diff --git a/test/langtools/tools/javac/preview/DeclaredUsingPreview.java b/test/langtools/tools/javac/preview/DeclaredUsingPreview.java deleted file mode 100644 index 403c471d1f613..0000000000000 --- a/test/langtools/tools/javac/preview/DeclaredUsingPreview.java +++ /dev/null @@ -1,11 +0,0 @@ -/** - * @test /nodynamiccopyright/ - * @bug 8250768 - * @summary Verify javac correctly reports errors for uses of classes declared using preview features. - * @compile/ref=DeclaredUsingPreview-source.out -XDrawDiagnostics --enable-preview -source ${jdk.version} -Xlint:preview DeclaredUsingPreview.java DeclaredUsingPreviewDeclarations.java - * @compile/ref=DeclaredUsingPreview-class.out -XDrawDiagnostics --enable-preview -source ${jdk.version} -Xlint:preview DeclaredUsingPreview.java - */ -public class DeclaredUsingPreview { - DeclaredUsingPreviewDeclarations.C c; - DeclaredUsingPreviewDeclarations.C2 c2; //TODO: should cause warning? -} diff --git a/test/langtools/tools/javac/preview/DeclaredUsingPreviewDeclarations.java b/test/langtools/tools/javac/preview/DeclaredUsingPreviewDeclarations.java deleted file mode 100644 index 0cf8b99791497..0000000000000 --- a/test/langtools/tools/javac/preview/DeclaredUsingPreviewDeclarations.java +++ /dev/null @@ -1,5 +0,0 @@ -///nodynamiccopyright/ -public class DeclaredUsingPreviewDeclarations { - sealed class C {} - non-sealed class C2 extends C {} -} diff --git a/test/langtools/tools/javac/preview/PreviewAutoSuppress.java b/test/langtools/tools/javac/preview/PreviewAutoSuppress.java index 59266dc27dfdf..2ae98cb349d69 100644 --- a/test/langtools/tools/javac/preview/PreviewAutoSuppress.java +++ b/test/langtools/tools/javac/preview/PreviewAutoSuppress.java @@ -96,17 +96,12 @@ public class Use { List expected = List.of("Outer.java:3:5: compiler.warn.preview.feature.use.plural: (compiler.misc.feature.records)", "Outer.java:3:5: compiler.warn.preview.feature.use.plural: (compiler.misc.feature.records)", - "Outer.java:4:5: compiler.warn.declared.using.preview: kindname.record, test.Outer.R", - "Use.java:3:8: compiler.warn.declared.using.preview: kindname.record, test.Outer.R", - "4 warnings"); + "2 warnings"); if (!log.equals(expected)) throw new Exception("expected output not found" + log); - checkPreviewClassfile(classes.resolve("test").resolve("Outer.class"), - true); //TODO: correct? - checkPreviewClassfile(classes.resolve("test").resolve("Outer$R.class"), - true); - checkPreviewClassfile(classes.resolve("test").resolve("Use.class"), - true); + checkPreviewClassfile(classes.resolve("test").resolve("Outer.class"), true); //TODO: correct? + checkPreviewClassfile(classes.resolve("test").resolve("Outer$R.class"),true); + checkPreviewClassfile(classes.resolve("test").resolve("Use.class"),false); } @Test diff --git a/test/langtools/tools/javac/preview/PreviewErrors.java b/test/langtools/tools/javac/preview/PreviewErrors.java index ae08e885ec3c0..b3d91ec05144c 100644 --- a/test/langtools/tools/javac/preview/PreviewErrors.java +++ b/test/langtools/tools/javac/preview/PreviewErrors.java @@ -234,9 +234,7 @@ public void doWork() throws IOException { new JavacTask(tb) .outdir(classesJavaBase) - .options("--patch-module", "java.base=" + srcJavaBase.toString(), - "--enable-preview", - "-source", String.valueOf(Runtime.version().feature())) + .options("--patch-module", "java.base=" + srcJavaBase.toString()) .files(tb.findJavaFiles(srcJavaBase)) .run() .writeAll(); @@ -244,7 +242,8 @@ public void doWork() throws IOException { task.withOption("--patch-module") .withOption("java.base=" + classesJavaBase.toString()) .withOption("--add-exports") - .withOption("java.base/user=ALL-UNNAMED"); + .withOption("java.base/user=ALL-UNNAMED") + .withOption("-XDforcePreview=true"); } case REFER_TO_DECLARATION_SOURCE -> { tb.writeJavaFiles(srcJavaBase, SEALED_DECLARATION); @@ -252,7 +251,8 @@ public void doWork() throws IOException { task.withOption("--patch-module") .withOption("java.base=" + srcJavaBase.toString()) .withOption("--add-exports") - .withOption("java.base/user=ALL-UNNAMED"); + .withOption("java.base/user=ALL-UNNAMED") + .withOption("-XDforcePreview=true"); } } @@ -289,11 +289,13 @@ public void test(Object o) { expected = Set.of("5:41:compiler.err.preview.feature.disabled"); } case REFER_TO_DECLARATION_CLASS -> { - ok = false; - expected = Set.of("-1:-1:compiler.err.preview.feature.disabled.classfile"); + ok = true; + previewClass = false; + expected = Set.of(); } case REFER_TO_DECLARATION_SOURCE -> { ok = false; + previewClass = false; expected = Set.of("2:8:compiler.err.preview.feature.disabled.plural"); } case API_CLASS, API_SOURCE -> { @@ -330,41 +332,16 @@ public void test(Object o) { } } case REFER_TO_DECLARATION_CLASS -> { - if (suppress == Suppress.YES) { - if (lint == Lint.ENABLE_PREVIEW) { - expected = Set.of("-1:-1:compiler.warn.preview.feature.use.classfile"); - } else { - expected = Set.of(/*"-1:-1:compiler.note.preview.filename", - "-1:-1:compiler.note.preview.recompile"*/); - } - } else if (lint == Lint.ENABLE_PREVIEW) { - expected = Set.of("5:13:compiler.warn.declared.using.preview", - "5:24:compiler.warn.declared.using.preview", - "-1:-1:compiler.warn.preview.feature.use.classfile"); - } else { - expected = Set.of("-1:-1:compiler.note.preview.filename", - "-1:-1:compiler.note.preview.recompile"); - } + previewClass = false; + expected = Set.of(); } case REFER_TO_DECLARATION_SOURCE -> { + previewClass = false; if (lint == Lint.ENABLE_PREVIEW) { - if (suppress == Suppress.YES) { - expected = Set.of("2:8:compiler.warn.preview.feature.use.plural", - "3:26:compiler.warn.declared.using.preview"); - } else { - expected = Set.of("5:13:compiler.warn.declared.using.preview", - "5:24:compiler.warn.declared.using.preview", - "2:8:compiler.warn.preview.feature.use.plural", - "3:26:compiler.warn.declared.using.preview"); - } + expected = Set.of("2:8:compiler.warn.preview.feature.use.plural"); } else { - if (suppress == Suppress.YES) { - expected = Set.of("-1:-1:compiler.note.preview.filename", - "-1:-1:compiler.note.preview.recompile"); - } else { - expected = Set.of("-1:-1:compiler.note.preview.plural", - "-1:-1:compiler.note.preview.recompile"); - } + expected = Set.of("-1:-1:compiler.note.preview.filename", + "-1:-1:compiler.note.preview.recompile"); } } case API_CLASS, API_SOURCE -> { diff --git a/test/langtools/tools/javac/processing/model/element/TestSealed.java b/test/langtools/tools/javac/processing/model/element/TestSealed.java index 70ca7c25afb91..0df8425f6820f 100644 --- a/test/langtools/tools/javac/processing/model/element/TestSealed.java +++ b/test/langtools/tools/javac/processing/model/element/TestSealed.java @@ -30,8 +30,7 @@ * jdk.compiler/com.sun.tools.javac.api * jdk.compiler/com.sun.tools.javac.main * @build toolbox.ToolBox toolbox.JavacTask JavacTestingAbstractProcessor - * @compile --enable-preview -source ${jdk.version} TestSealed.java - * @run main/othervm --enable-preview TestSealed + * @run main TestSealed */ import java.io.*; @@ -130,16 +129,12 @@ class ClassOutOfSealedHierarchy extends NonSealedClass1 {} "- compiler.note.proc.messager: visiting: NonSealedClass2 Modifiers: [non-sealed]", "- compiler.note.proc.messager: this class has: 0, permitted subclasses", "- compiler.note.proc.messager: visiting: ClassOutOfSealedHierarchy Modifiers: []", - "- compiler.note.proc.messager: this class has: 0, permitted subclasses", - "- compiler.note.preview.filename: SealedInterface.java, DEFAULT", - "- compiler.note.preview.recompile" + "- compiler.note.proc.messager: this class has: 0, permitted subclasses" ); for (Mode mode : new Mode[] {Mode.API}) { List log = new JavacTask(tb, mode) .options("-processor", SealedClassesProcessor.class.getName(), - "--enable-preview", - "-source", Integer.toString(Runtime.version().feature()), "-XDrawDiagnostics") .files(findJavaFiles(src)) .outdir(classes) diff --git a/test/langtools/tools/javac/sealed/SealedCompilationTests.java b/test/langtools/tools/javac/sealed/SealedCompilationTests.java index d20ee27d126bd..54f4a5bf2325e 100644 --- a/test/langtools/tools/javac/sealed/SealedCompilationTests.java +++ b/test/langtools/tools/javac/sealed/SealedCompilationTests.java @@ -33,9 +33,8 @@ * jdk.compiler/com.sun.tools.javac.api * jdk.compiler/com.sun.tools.javac.main * @build toolbox.ToolBox toolbox.JavacTask - * @compile --enable-preview -source ${jdk.version} SealedCompilationTests.java - * @run testng/othervm -DuseAP=false --enable-preview SealedCompilationTests - * @run testng/othervm -DuseAP=true --enable-preview SealedCompilationTests + * @run testng/othervm -DuseAP=false SealedCompilationTests + * @run testng/othervm -DuseAP=true SealedCompilationTests */ import java.lang.constant.ClassDesc; @@ -77,17 +76,7 @@ public class SealedCompilationTests extends CompilationTestCase { ToolBox tb = new ToolBox(); - // When sealed classes become a permanent feature, we don't need these any more - private static String[] PREVIEW_OPTIONS = { - "--enable-preview", - "-source", Integer.toString(Runtime.version().feature()) - }; - - private static String[] PREVIEW_OPTIONS_WITH_AP = { - "--enable-preview", - "-source", Integer.toString(Runtime.version().feature()), - "-processor", SimplestAP.class.getName() - }; + private static String[] OPTIONS_WITH_AP = { "-processor", SimplestAP.class.getName() }; /* simplest annotation processor just to force a round of annotation processing for all tests */ @@ -108,7 +97,7 @@ public SourceVersion getSupportedSourceVersion() { public SealedCompilationTests() { boolean useAP = System.getProperty("useAP") == null ? false : System.getProperty("useAP").equals("true"); setDefaultFilename("SealedTest.java"); - setCompileOptions(useAP ? PREVIEW_OPTIONS_WITH_AP : PREVIEW_OPTIONS); + setCompileOptions(useAP ? OPTIONS_WITH_AP : new String[]{}); System.out.println(useAP ? "running all tests using an annotation processor" : "running all tests without annotation processor"); } @@ -298,22 +287,6 @@ public void testRestrictedKeyword() { )) { assertFail("compiler.err.restricted.type.not.allowed.here", s); } - - String[] testOptions = {/* no options */}; - String[] previousCompOptions = getCompileOptions(); - setCompileOptions(testOptions); - // now testing with preview disabled - for (String s : List.of( - "sealed class S {}", - "class Outer { sealed class S {} }", - "class Outer { void m() { sealed class S {} } }", - "non-sealed class S {}", - "class Outer { non-sealed class S {} }", - "class Outer { void m() { non-sealed class S {} } }" - )) { - assertFail("compiler.err.preview.feature.disabled.plural", s); - } - setCompileOptions(previousCompOptions); } public void testRejectPermitsInNonSealedClass() { diff --git a/test/langtools/tools/javac/sealed/SealedDiffConfigurationsTest.java b/test/langtools/tools/javac/sealed/SealedDiffConfigurationsTest.java index 92beb53e88d44..9dc45dcf5e3de 100644 --- a/test/langtools/tools/javac/sealed/SealedDiffConfigurationsTest.java +++ b/test/langtools/tools/javac/sealed/SealedDiffConfigurationsTest.java @@ -92,7 +92,6 @@ public void testSameCompilationUnitPos(Path base) throws Exception { new JavacTask(tb) .outdir(out) - .options("--enable-preview", "-source", Integer.toString(Runtime.version().feature())) .files(findJavaFiles(test)) .run() .writeAll(); @@ -121,7 +120,6 @@ public void testSameCompilationUnitPos2(Path base) throws Exception { new JavacTask(tb) .outdir(out) .files(findJavaFiles(test)) - .options("--enable-preview", "-source", Integer.toString(Runtime.version().feature())) .run() .writeAll(); @@ -188,7 +186,6 @@ public void testSamePackagePos(Path base) throws Exception { new JavacTask(tb) .outdir(out) .files(findJavaFiles(pkg)) - .options("--enable-preview", "-source", Integer.toString(Runtime.version().feature())) .run() .writeAll(); @@ -210,7 +207,7 @@ public void testSameCompilationUnitNeg(Path base) throws Exception { "}"); List error = new JavacTask(tb) - .options("-XDrawDiagnostics", "--enable-preview", "-source", Integer.toString(Runtime.version().feature())) + .options("-XDrawDiagnostics") .files(findJavaFiles(test)) .run(Task.Expect.FAIL) .writeAll() @@ -236,7 +233,7 @@ public void testSameCompilationUnitNeg2(Path base) throws Exception { "}"); List error = new JavacTask(tb) - .options("-XDrawDiagnostics", "--enable-preview", "-source", Integer.toString(Runtime.version().feature())) + .options("-XDrawDiagnostics") .files(findJavaFiles(test)) .run(Task.Expect.FAIL) .writeAll() @@ -275,7 +272,7 @@ public void testSamePackageNeg(Path base) throws Exception { "}"); List error = new JavacTask(tb) - .options("-XDrawDiagnostics", "--enable-preview", "-source", Integer.toString(Runtime.version().feature())) + .options("-XDrawDiagnostics") .files(findJavaFiles(pkg)) .run(Task.Expect.FAIL) .writeAll() @@ -309,7 +306,7 @@ public void testSamePackageNeg2(Path base) throws Exception { "}"); List error = new JavacTask(tb) - .options("-XDrawDiagnostics", "--enable-preview", "-source", Integer.toString(Runtime.version().feature())) + .options("-XDrawDiagnostics") .files(findJavaFiles(pkg)) .run(Task.Expect.FAIL) .writeAll() @@ -342,7 +339,7 @@ public void testSamePackageNeg3(Path base) throws Exception { "}"); List error = new JavacTask(tb) - .options("-XDrawDiagnostics", "--enable-preview", "-source", Integer.toString(Runtime.version().feature())) + .options("-XDrawDiagnostics") .files(findJavaFiles(pkg)) .run(Task.Expect.FAIL) .writeAll() @@ -377,7 +374,7 @@ public void testDiffPackageNeg(Path base) throws Exception { "}"); List error = new JavacTask(tb) - .options("-XDrawDiagnostics", "--enable-preview", "-source", Integer.toString(Runtime.version().feature())) + .options("-XDrawDiagnostics") .files(findJavaFiles(pkg1, pkg2)) .run(Task.Expect.FAIL) .writeAll() @@ -413,7 +410,7 @@ public void testDiffPackageNeg2(Path base) throws Exception { "}"); List error = new JavacTask(tb) - .options("-XDrawDiagnostics", "--enable-preview", "-source", Integer.toString(Runtime.version().feature())) + .options("-XDrawDiagnostics") .files(findJavaFiles(pkg1, pkg2)) .run(Task.Expect.FAIL) .writeAll() @@ -453,7 +450,7 @@ public void testDiffPackageNeg3(Path base) throws Exception { Files.createDirectories(out); List error = new JavacTask(tb) - .options("-XDrawDiagnostics", "--enable-preview", "-source", Integer.toString(Runtime.version().feature())) + .options("-XDrawDiagnostics") .files(findJavaFiles(pkg1, pkg2)) .run(Task.Expect.FAIL) .writeAll() @@ -479,7 +476,7 @@ public void testSameModuleSamePkgPos(Path base) throws Exception { tb.createDirectories(classes); new JavacTask(tb) - .options("--module-source-path", src.toString(), "--enable-preview", "-source", Integer.toString(Runtime.version().feature())) + .options("--module-source-path", src.toString()) .outdir(classes) .files(findJavaFiles(src)) .run() @@ -498,7 +495,7 @@ public void testSameModuleDiffPkgPos(Path base) throws Exception { tb.createDirectories(classes); new JavacTask(tb) - .options("--module-source-path", src.toString(), "--enable-preview", "-source", Integer.toString(Runtime.version().feature())) + .options("--module-source-path", src.toString()) .outdir(classes) .files(findJavaFiles(src)) .run() @@ -519,8 +516,7 @@ public void testSameModuleSamePkgNeg1(Path base) throws Exception { List error = new JavacTask(tb) .options("-XDrawDiagnostics", "--module-source-path", - src.toString(), "--enable-preview", - "-source", Integer.toString(Runtime.version().feature())) + src.toString()) .outdir(classes) .files(findJavaFiles(src)) .run(Task.Expect.FAIL) @@ -550,8 +546,7 @@ public void testSameModuleSamePkgNeg2(Path base) throws Exception { List error = new JavacTask(tb) .options("-XDrawDiagnostics", "--module-source-path", - src.toString(), "--enable-preview", - "-source", Integer.toString(Runtime.version().feature())) + src.toString()) .outdir(classes) .files(findJavaFiles(src)) .run(Task.Expect.FAIL) @@ -590,9 +585,7 @@ public void testDifferentModuleNeg(Path base) throws Exception { new JavacTask(tb) .options("-XDrawDiagnostics", "--module-source-path", src.toString(), - "--add-reads", "mSealed=mSub", - "--enable-preview", - "-source", Integer.toString(Runtime.version().feature())) + "--add-reads", "mSealed=mSub") .outdir(classes) .files(findJavaFiles(src)) .run(Task.Expect.FAIL) @@ -601,8 +594,6 @@ public void testDifferentModuleNeg(Path base) throws Exception { List expected = List.of( "Base.java:1:46: compiler.err.class.in.module.cant.extend.sealed.in.diff.module: a.Base, mSealed", - "- compiler.note.preview.plural: DEFAULT", - "- compiler.note.preview.recompile", "1 error" ); if (!error.containsAll(expected)) { @@ -623,8 +614,7 @@ public void testSeparateCompilation(Path base) throws Exception { new JavacTask(tb) .options("-XDrawDiagnostics", "--module-source-path", - src.toString(), "--enable-preview", - "-source", Integer.toString(Runtime.version().feature())) + src.toString()) .outdir(classes) .files(findJavaFiles(src_m)) .run() @@ -633,8 +623,7 @@ public void testSeparateCompilation(Path base) throws Exception { new JavacTask(tb) .options("-XDrawDiagnostics", "--module-source-path", - src.toString(), "--enable-preview", "-doe", - "-source", Integer.toString(Runtime.version().feature())) + src.toString(), "-doe") .outdir(classes) .files(findJavaFiles(src_m.resolve("pkg").resolve("a"))) .run() @@ -643,8 +632,7 @@ public void testSeparateCompilation(Path base) throws Exception { new JavacTask(tb) .options("-XDrawDiagnostics", "--module-source-path", - src.toString(), "--enable-preview", "-doe", - "-source", Integer.toString(Runtime.version().feature())) + src.toString(), "-doe") .outdir(classes) .files(findJavaFiles(src_m.resolve("pkg").resolve("b"))) .run() @@ -656,8 +644,7 @@ public void testSeparateCompilation(Path base) throws Exception { //implicit compilations: new JavacTask(tb) .options("-XDrawDiagnostics", "--module-source-path", - src.toString(), "--enable-preview", "-doe", - "-source", Integer.toString(Runtime.version().feature())) + src.toString(), "-doe") .outdir(classes) .files(findJavaFiles(src_m.resolve("pkg").resolve("a"))) .run() @@ -668,8 +655,7 @@ public void testSeparateCompilation(Path base) throws Exception { new JavacTask(tb) .options("-XDrawDiagnostics", "--module-source-path", - src.toString(), "--enable-preview", "-doe", - "-source", Integer.toString(Runtime.version().feature())) + src.toString(), "-doe") .outdir(classes) .files(findJavaFiles(src_m.resolve("pkg").resolve("b"))) .run() diff --git a/test/langtools/tools/jdeps/listdeps/ListModuleDeps.java b/test/langtools/tools/jdeps/listdeps/ListModuleDeps.java index 0f014f4bc3613..b82baa41d660c 100644 --- a/test/langtools/tools/jdeps/listdeps/ListModuleDeps.java +++ b/test/langtools/tools/jdeps/listdeps/ListModuleDeps.java @@ -92,7 +92,6 @@ public void compileAll() throws Exception { public Object[][] jdkModules() { return new Object[][]{ {"jdk.compiler", new String[]{ - "java.base/jdk.internal.javac", "java.base/jdk.internal.jmod", "java.base/jdk.internal.misc", "java.base/sun.reflect.annotation",