I am using a method from a third party library (Reflections) which is supposed to find subtypes of the given type and looks like
public <T> Set<Class<? extends T>> getSubTypesOf(final Class<T> type) {
...
When the caller code looks like
Class<?> type = ...
Set<Class<?>> subTypes = reflections.getSubTypesOf(type);
I am getting a compile error: "cannot convert from Set<Class<? extends capture#19-of ?>> to Set<Class<?>>
". The following fixes the situation:
Class<?> type = ...
Set<?> subTypes = reflections.getSubTypesOf(ht);
so it looks like the only possible remedy for incorrect Set<Class<? extends ?>>
would be Set<?>
but not Set<Class<?>>
. Why is it so?
Thanks for any explanation on this.