RFR: 8246778: Compiler implementation for Sealed Classes (Second Preview)

Dan Smith dlsmith at openjdk.java.net
Wed Dec 2 19:34:59 UTC 2020

On Wed, 2 Dec 2020 17:57:22 GMT, Mandy Chung <mchung at openjdk.org> wrote:

> I suggest `Class::getPermittedSubclasses` to return a `non-null` array if this `Class` is sealed, i.e. this class is derived from a `class` file with the presence of `PermittedSubclasses` attribute regardless of its content (the attribute could be empty or contains zero or more entries which is a properly loaded permitted subtype.
> If this `Class` is not sealed, `Class::getPermittedSubclasses` returns null (see `Class::getRecordComponents` and some other reflection APIs as precedence).

Agree, that seems reasonable. Often, methods in `Class` with an array return type default to an empty array, but `getRecordComponents` is a good example of returning `null` when an empty array is meaningful.


PR: https://git.openjdk.java.net/jdk/pull/1483

More information about the compiler-dev mailing list