> On 27 Oct 2020, at 11:51, [email protected] wrote:
> 
>> ...
>> Since the set of permitted classes must be subclasses of T, should the
>> declaration be:
>> 
>> public Class<? extends T>[] getPermittedSubclasses() { .. }
> 
> 
> Hi Chris,
> in theory yes,
> in practice, an array of parametrized types is usually unsafe, in this 
> peculiar case, it's always unsafe because you can write
> 
> Class<? extends Itf>[] array = Itf.class.getPermittedSubclasses();
> Object[] array2 = array;
> array2[0] = Object.class;
> 
> Itf itf = array[0].newInstance();  // CCE, the compiler insert a cast to Itf 
> and Object doesn't implement Itf

Thanks for the explanation Remi - I fell afoul of generics 101 ;-)  

-Chris.

Reply via email to