JDK-8265320 : implement Sealed Classes as a standard feature in Java, javax.lang.model changes
  • Type: CSR
  • Component: core-libs
  • Sub-Component: javax.lang.model
  • Priority: P3
  • Status: Closed
  • Resolution: Approved
  • Fix Versions: 17
  • Submitted: 2021-04-16
  • Updated: 2021-04-16
  • Resolved: 2021-04-16
Related Reports
CSR :  
Description
Summary
-------

JEP 409 proposes that the Sealed Classes feature is ready to be made final and permanent. Currently the `javax.lang.model` APIs only support Sealed Classes as a preview feature. Making the feature standard in Java will affect these APIs.

Problem
-------

The preview status of `javax.lang.model` APIs that support the Sealed Classes feature should be updated so that they can be used in standard Java.

Solution
--------

Update `javax.lang.model` APIs that support the Sealed Classes feature so that they can be used in standard Java

Specification
-------------

    diff --git a/src/java.compiler/share/classes/javax/lang/model/element/Modifier.java b/src/java.compiler/share/classes/javax/lang/model/element/Modifier.java
    index 8ba4ab6a2be..dfbd76d2bf1 100644
    --- a/src/java.compiler/share/classes/javax/lang/model/element/Modifier.java
    +++ b/src/java.compiler/share/classes/javax/lang/model/element/Modifier.java
    @@ -67,18 +67,14 @@ public enum Modifier {
     
         /**
          * The modifier {@code sealed}
    -     * @since 15
    +     * @since 17
          */
    -    @jdk.internal.javac.PreviewFeature(feature=jdk.internal.javac.PreviewFeature.Feature.SEALED_CLASSES,
    -                                             reflective=true)
         SEALED,
     
         /**
          * The modifier {@code non-sealed}
    -     * @since 15
    +     * @since 17
          */
    -    @jdk.internal.javac.PreviewFeature(feature=jdk.internal.javac.PreviewFeature.Feature.SEALED_CLASSES,
    -            reflective=true)
         NON_SEALED {
             public String toString() {
                 return "non-sealed";
    diff --git a/src/java.compiler/share/classes/javax/lang/model/element/TypeElement.java b/src/java.compiler/share/classes/javax/lang/model/element/TypeElement.java
    index ac078309522..3d73a937b78 100644
    --- a/src/java.compiler/share/classes/javax/lang/model/element/TypeElement.java
    +++ b/src/java.compiler/share/classes/javax/lang/model/element/TypeElement.java
    @@ -207,10 +207,8 @@ public interface TypeElement extends Element, Parameterizable, QualifiedNameable
          *
          * @return the permitted classes, or an empty list if there are none
          *
    -     * @since 15
    +     * @since 17
          */
    -    @jdk.internal.javac.PreviewFeature(feature=jdk.internal.javac.PreviewFeature.Feature.SEALED_CLASSES,
    -                                 reflective=true)
         default List<? extends TypeMirror> getPermittedSubclasses() {
             return List.of();
         }

Comments
Moving to Approved.
16-04-2021