RFR: 8246778: Compiler implementation for Sealed Classes (Second Preview)
jlahoda at openjdk.java.net
Thu Dec 3 14:40:55 UTC 2020
On Thu, 3 Dec 2020 14:08:48 GMT, Jan Lahoda <jlahoda 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.
> I've changed Class.getPermittedSubclasses to return null for classes that are not sealed here:
> with follow-up changes to tests here:
> How does this look?
After a discussion with Harold, I've reverted the patch where Class.getPermittedSubclasses returns null. Harold will do that separatelly under JDK-8256867, unless there are objections.
The changes that were reverted are still available here:
Please let me know if there are any issues.
More information about the compiler-dev