JDK-8246278 : Refine API for sealing in java.lang.Class
  • Type: Enhancement
  • Component: core-libs
  • Sub-Component: java.lang:reflect
  • Affected Version: 15
  • Priority: P4
  • Status: Resolved
  • Resolution: Not an Issue
  • Submitted: 2020-06-01
  • Updated: 2020-12-12
  • Resolved: 2020-12-12
Related Reports
Relates :  
Relates :  
Relates :  
Description
Several alternatives exist for how information about sealing can be revealed through the java.lang.Class API. These include other names for the "permittedSubclasses" method to better capture that direct subclasses and direct subinterfaces are allowed and using an immutable list rather than an array as the aggregate in the return type.
Comments
`Class::permittedSubclasses` that returns ClassDesc[] has been changed to return Class<?>[] [1]. As this is the current (old) style of the reflection API, the method name should also follow the same naming convention `getXXX`. So this is renamed to `Class::getPermittedSubclasses` in Java SE 16. [1] https://mail.openjdk.java.net/pipermail/amber-spec-experts/2020-October/002597.html
12-12-2020

A point for consideration, the return type. Returning a Class<?>[] or maybe an immutable List<Class<? extendsT>>. The latter allows for sharper type information in the signature, the former does not ( see https://mail.openjdk.java.net/pipermail/amber-spec-experts/2020-October/002625.html ).
05-11-2020