changeset 60093:cd6d50f2124a amber-demo-II

Automatic merge with sealed-types
author mcimadamore
date Fri, 28 Feb 2020 21:35:43 +0000
parents 67525d425cf7 a631c875d3bc
children c35f1585204b
files src/java.base/share/classes/java/lang/Class.java src/java.compiler/share/classes/javax/lang/model/element/TypeElement.java src/jdk.compiler/share/classes/com/sun/tools/javac/code/Flags.java
diffstat 4 files changed, 76 insertions(+), 27 deletions(-) [+]
line wrap: on
line diff
--- a/src/java.base/share/classes/java/lang/Class.java	Fri Feb 28 04:00:45 2020 +0000
+++ b/src/java.base/share/classes/java/lang/Class.java	Fri Feb 28 21:35:43 2020 +0000
@@ -4226,13 +4226,25 @@
     }
 
     /**
+     * {@preview Associated with sealed types, a preview feature of the Java language.
+     *
+     *           This method is associated with <i>sealed types</i>, a preview
+     *           feature of the Java language. Preview features
+     *           may be removed in a future release, or upgraded to permanent
+     *           features of the Java language.}
+     *
      * Returns an array containing {@code ClassDesc} objects representing all the
-     * permitted subtypes of this class if it is sealed. Returns an empty array if this
-     * class is not sealed.
+     * permitted subtypes of this {@linkplain Class} if it is sealed. Returns an empty array if this
+     * {@linkplain Class} is not sealed.
+     *
      * @return an array of class descriptors of all the permitted subtypes of this class
      * @throws IllegalArgumentException if a class descriptor is not in the correct format
-     * @since 14
+     *
+     * @jls 8.1 Class Declarations
+     * @jls 9.1 Interface Declarations
+     * @since 15
      */
+    @jdk.internal.PreviewFeature(feature=jdk.internal.PreviewFeature.Feature.SEALED_TYPES, essentialAPI=false)
     public ClassDesc[] getPermittedSubtypes() {
         String[] descriptors = getPermittedSubtypes0();
         if (descriptors == null || descriptors.length == 0) {
@@ -4248,10 +4260,23 @@
     }
 
     /**
-     * Returns true if this class or interface is sealed.
-     * @return returns true if the class or interface is sealed
-     * @since 14
+     * * {@preview Associated with sealed types, a preview feature of the Java language.
+     *
+     *           This method is associated with <i>sealed types</i>, a preview
+     *           feature of the Java language. Preview features
+     *           may be removed in a future release, or upgraded to permanent
+     *           features of the Java language.}
+     *
+     * Returns true if this {@linkplain Class} is sealed.
+     *
+     * @return returns true if this class is sealed
+     *
+     * @jls 8.1 Class Declarations
+     * @jls 9.1 Interface Declarations
+     * @since 15
      */
+    @jdk.internal.PreviewFeature(feature=jdk.internal.PreviewFeature.Feature.SEALED_TYPES, essentialAPI=false)
+    @SuppressWarnings("preview")
     public boolean isSealed() {
         return getPermittedSubtypes().length != 0;
     }
--- a/src/java.compiler/share/classes/javax/lang/model/element/Modifier.java	Fri Feb 28 04:00:45 2020 +0000
+++ b/src/java.compiler/share/classes/javax/lang/model/element/Modifier.java	Fri Feb 28 21:35:43 2020 +0000
@@ -59,11 +59,36 @@
      */
      DEFAULT,
     /** The modifier {@code static} */          STATIC,
+
     /**
+     * {@preview Associated with sealed types, a preview feature of the Java language.
+     *
+     *           This enum constant is associated with <i>sealed types</i>, a preview
+     *           feature of the Java language. Preview features
+     *           may be removed in a future release, or upgraded to permanent
+     *           features of the Java language.}
+     *
      * The modifier {@code sealed}
-     * @since amber
+     * @since 15
      */
-    SEALED, // Not sure this the best order; certainly after public/private.
+    @jdk.internal.PreviewFeature(feature=jdk.internal.PreviewFeature.Feature.SEALED_TYPES,
+                                             essentialAPI=false)
+    SEALED,
+
+    /**
+     * {@preview Associated with sealed types, a preview feature of the Java language.
+     *
+     *           This enum constant is associated with <i>sealed types</i>, a preview
+     *           feature of the Java language. Preview features
+     *           may be removed in a future release, or upgraded to permanent
+     *           features of the Java language.}
+     *
+     * The modifier {@code non-sealed}
+     * @since 15
+     */
+    @jdk.internal.PreviewFeature(feature=jdk.internal.PreviewFeature.Feature.SEALED_TYPES,
+            essentialAPI=false)
+    NON_SEALED,
     /** The modifier {@code final} */           FINAL,
     /** The modifier {@code transient} */       TRANSIENT,
     /** The modifier {@code volatile} */        VOLATILE,
--- a/src/java.compiler/share/classes/javax/lang/model/element/TypeElement.java	Fri Feb 28 04:00:45 2020 +0000
+++ b/src/java.compiler/share/classes/javax/lang/model/element/TypeElement.java	Fri Feb 28 21:35:43 2020 +0000
@@ -217,14 +217,13 @@
      * @implSpec The default implementations of this method returns an
      * empty and unmodifiable list.
      *
-     * @return the permitted subtypes, or an empty list
-     * if there are none
+     * @return the permitted subtypes, or an empty list if there are none
      *
-     * @since amber
+     * @since 15
      */
     @jdk.internal.PreviewFeature(feature=jdk.internal.PreviewFeature.Feature.SEALED_TYPES,
                                  essentialAPI=false)
-    @SuppressWarnings("preview")
+    //@SuppressWarnings("preview")
     default List<? extends TypeMirror> getPermittedSubtypes() {
         return List.of();
     }
--- a/src/jdk.compiler/share/classes/com/sun/tools/javac/code/Flags.java	Fri Feb 28 04:00:45 2020 +0000
+++ b/src/jdk.compiler/share/classes/com/sun/tools/javac/code/Flags.java	Fri Feb 28 21:35:43 2020 +0000
@@ -405,25 +405,25 @@
         LocalVarFlags               = FINAL | PARAMETER,
         ReceiverParamFlags          = PARAMETER;
 
-
+    @SuppressWarnings("preview")
     public static Set<Modifier> asModifierSet(long flags) {
         Set<Modifier> modifiers = modifierSets.get(flags);
         if (modifiers == null) {
             modifiers = java.util.EnumSet.noneOf(Modifier.class);
-            if (0 != (flags & PUBLIC))    modifiers.add(Modifier.PUBLIC);
-            if (0 != (flags & PROTECTED)) modifiers.add(Modifier.PROTECTED);
-            if (0 != (flags & PRIVATE))   modifiers.add(Modifier.PRIVATE);
-            if (0 != (flags & ABSTRACT))  modifiers.add(Modifier.ABSTRACT);
-            if (0 != (flags & STATIC))    modifiers.add(Modifier.STATIC);
-            if (0 != (flags & SEALED))    modifiers.add(Modifier.SEALED);
-            if (0 != (flags & FINAL))     modifiers.add(Modifier.FINAL);
-            if (0 != (flags & TRANSIENT)) modifiers.add(Modifier.TRANSIENT);
-            if (0 != (flags & VOLATILE))  modifiers.add(Modifier.VOLATILE);
-            if (0 != (flags & SYNCHRONIZED))
-                                          modifiers.add(Modifier.SYNCHRONIZED);
-            if (0 != (flags & NATIVE))    modifiers.add(Modifier.NATIVE);
-            if (0 != (flags & STRICTFP))  modifiers.add(Modifier.STRICTFP);
-            if (0 != (flags & DEFAULT))   modifiers.add(Modifier.DEFAULT);
+            if (0 != (flags & PUBLIC))        modifiers.add(Modifier.PUBLIC);
+            if (0 != (flags & PROTECTED))     modifiers.add(Modifier.PROTECTED);
+            if (0 != (flags & PRIVATE))       modifiers.add(Modifier.PRIVATE);
+            if (0 != (flags & ABSTRACT))      modifiers.add(Modifier.ABSTRACT);
+            if (0 != (flags & STATIC))        modifiers.add(Modifier.STATIC);
+            if (0 != (flags & SEALED))        modifiers.add(Modifier.SEALED);
+            if (0 != (flags & NON_SEALED))    modifiers.add(Modifier.NON_SEALED);
+            if (0 != (flags & FINAL))         modifiers.add(Modifier.FINAL);
+            if (0 != (flags & TRANSIENT))     modifiers.add(Modifier.TRANSIENT);
+            if (0 != (flags & VOLATILE))      modifiers.add(Modifier.VOLATILE);
+            if (0 != (flags & SYNCHRONIZED))  modifiers.add(Modifier.SYNCHRONIZED);
+            if (0 != (flags & NATIVE))        modifiers.add(Modifier.NATIVE);
+            if (0 != (flags & STRICTFP))      modifiers.add(Modifier.STRICTFP);
+            if (0 != (flags & DEFAULT))       modifiers.add(Modifier.DEFAULT);
             modifiers = Collections.unmodifiableSet(modifiers);
             modifierSets.put(flags, modifiers);
         }