8260517: implement Sealed Classes as a standard feature in Java

Co-authored-by: Harold Seigel <hseigel@openjdk.org>
Co-authored-by: Vicente Romero <vromero@openjdk.org>
Reviewed-by: dholmes, mcimadamore, jlahoda
This commit is contained in:
Vicente Romero 2021-05-20 09:11:08 +00:00
parent 31b98e129e
commit 0fa9223f34
54 changed files with 170 additions and 394 deletions

View file

@ -4475,9 +4475,8 @@ public final class Class<T> implements java.io.Serializable,
*
* @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 @@ public final class Class<T> implements java.io.Serializable,
* 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;