Uploaded image for project: 'JDK'
  1. JDK
  2. JDK-8265320

implement Sealed Classes as a standard feature in Java, javax.lang.model changes

    XMLWordPrintable

    Details

    • Type: CSR
    • Status: Closed
    • Priority: P3
    • Resolution: Approved
    • Fix Version/s: 17
    • Component/s: core-libs
    • Labels:
      None
    • Subcomponent:
    • Compatibility Kind:
      behavioral
    • Compatibility Risk:
      minimal
    • Compatibility Risk Description:
      No change in behavior other than reducing warnings. Provides unrestricted use of a new feature.
    • Interface Kind:
      Java API
    • Scope:
      SE

      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();
           }

        Attachments

          Issue Links

            Activity

              People

              Assignee:
              vromero Vicente Arturo Romero Zaldivar
              Reporter:
              vromero Vicente Arturo Romero Zaldivar
              Reviewed By:
              Gavin Bierman, Joe Darcy
              Votes:
              0 Vote for this issue
              Watchers:
              1 Start watching this issue

                Dates

                Created:
                Updated:
                Resolved: