On Wed, 2 Dec 2020 14:28:00 GMT, Harold Seigel <hsei...@openjdk.org> wrote:

> Additional changes may be needed to Class.permittedSubclasses() and/or 
> Class.isSealed() as part of fixing bug JDK-8256867. The JVM is being changed 
> to treat classes with empty PermittedSubclasses attributes as sealed classes 
> that cannot be extended (or implemented).
> 
> Current thinking is that Class.permittedSubclasses() will return an empty 
> array for both non-sealed classes and for sealed classes with empty 
> PermittedSubclasses attributes. And, Class.isSealed() will return False in 
> the former case and True in the latter. This will require changing the 
> implementation of Class.isSealed() to call the JVM directly instead of 
> calling Class.permittedSubclasses().
> 
> Does this seem like a reasonable way to handle this corner case?

Uh, I just realized it may be necessary to implement `Class.isSealed()` 
differently. Consider:
sealed class Sealed permits Unknown {}

Where `Unknown` does not exist at runtime. So getPermittedSubclasses0() returns 
an empty array(?). But isSealed should return `true`, right? (Possibly, we 
could leave this from the first integration, but seems like something that 
should be done. Note that in the previous/JDK 15 implementation, isSealed() 
would return true in this case.)

-------------

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

Reply via email to