> On 29 Oct 2020, at 21:38, Dan Smith <[email protected]> wrote: > >> ... > > You're not wrong, but I'm not sure this is reason not to provide better > typing information. It certainly is the contract of the > 'getPermittedSubclasses' method not to pollute it with non-subclasses of T. > > That said, Class<?>[] seems to be the precedent followed by other methods: > > Class<? super T> getSuperclass() > vs. > Class<?>[] getInterfaces() > > Constructor<T> getConstructor(Class<?>) > vs. > Constructor<?>[] getConstructors() > > So I guess we should do the same with 'getPermittedSubclasses'.
For reference, 8246278 "Refine API for sealing in java.lang.Class” [1], tracks this issue. An additional point for consideration, the return "container". Returning a Class<?>[] or maybe an immutable List<? extendsT>. The latter allows for sharper type information in the signature, the former does not. -Chris. [1] https://bugs.openjdk.java.net/browse/JDK-8246278
