Summary
Sealed Classes were originally proposed by JEP 360 in 2019 and was targeted to JDK 15 as a preview feature. Feedback on the feature was positive. Some changes were proposed including the enhancement of narrowing reference conversion to perform stricter checking of cast conversions with respect to sealed type hierarchies. Sealed Classes were proposed again by JEP 397 and targeted to JDK 16, again as a preview feature. Feedback suggests that the Sealed Classes feature is now ready to be made final and permanent as proposed by JEP 409.
Problem
The preview status of Sealed Classes prevents usage in standard Java.
Solution
Remove the preview status requirement from Sealed Classes related APIs.
Specification
This CSR is concerned only with removing the preview status from the API. The changes are listed below.
Note: apart from the changes to java.lang.Class
related API a small change to the API of com.sun.source.tree.ClassTree
is also included.
diff --git a/src/java.base/share/classes/java/lang/Class.java b/src/java.base/share/classes/java/lang/Class.java
*
* @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() { ... }
* 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() { ... }
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
@@ -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<? extends Tree> getPermitsClause() { ... }
- csr of
-
JDK-8260517 implement Sealed Classes as a standard feature in Java
- Resolved
- relates to
-
JDK-8260515 JLS changes for Sealed Classes
- Resolved
-
JDK-8260516 JVMS changes for Sealed Classes
- Resolved