Summary
-------
Add support for _sealed classes_ in `core-libs`. Sealed classes are classes
or interfaces that restrict which other classes or interfaces may extend or
implement them.
Problem
-------
Sealed classes, see ([JEP 360](http://openjdk.java.net/jeps/360)), will be
previewed in Java SE 15 and support will be needed for them in `core-libs`.
In particular some reflection support will be needed in order to find out if a class or interface is sealed or not and to access a class' permitted subclasses if applicable
Solution
--------
Enhance `core-libs` to support sealed classes as follows.
- Add a new predicate to `java.lang.Class` to query if the given `class` is sealed or not.
- Also add another method to `java.lang.Class` which returns an array of `java.lang.constant.ClassDesc` containing the permitted subclasses. This array can only be empty if the given `class` is not sealed.
Specification
-------------
/**
* {@preview Associated with sealed classes, a preview feature of the Java language.
*
* This method is associated with <i>sealed classes</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
* direct subclasses or direct implementation classes permitted to extend or implement this class or interface
* if it is sealed. If this {@code Class} object represents a primitive type, {@code void}, an array type,
* or a class or interface that is not sealed, an empty array is returned.
*
* @return an array of class descriptors of all the permitted subclasses of this class or interface
*
* @jls 8.1 Class Declarations
* @jls 9.1 Interface Declarations
* @since 15
*/
@jdk.internal.PreviewFeature(feature=jdk.internal.PreviewFeature.Feature.SEALED_CLASSES, essentialAPI=false)
public ClassDesc[] permittedSubclasses() {}
/**
* * {@preview Associated with sealed classes, a preview feature of the Java language.
*
* This method is associated with <i>sealed classes</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 {@code true} if and only if this {@code Class} object represents a sealed class or interface.
* If this {@code Class} object represents a primitive type, {@code void}, or an array type, this method returns
* {@code false}.
*
* @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
*/
@jdk.internal.PreviewFeature(feature=jdk.internal.PreviewFeature.Feature.SEALED_CLASSES, essentialAPI=false)
@SuppressWarnings("preview")
public boolean isSealed() {}
Additional links
-------
* javadoc: http://cr.openjdk.java.net/~vromero/sealed_CSRs/core-libs/javadoc.00/module-summary.html
* specdiff: http://cr.openjdk.java.net/~vromero/sealed_CSRs/core-libs/specdiff.00/overview-summary.html