I guess this is a very confusing title, but I don't know what else to call - probably answered somewhere as well, but I couldn't find anything. Take this example:
List<Class<? extends Integer>> myList;
void foo() {
bar(myList);
}
void bar(List<Class<?>> a) { /* ... */ }
It doesn't compile (not applicable arguments, it says). If I remove the bounding it works fine:
List<Class<?>> myList;
void foo() {
bar(myList);
}
void bar(List<Class<?>> a) { /* ... */ }
Class<? extends Integer>
is just more specific than Class<?>
. How come it stops working? Note that this problem is only in the second level generics. If there wasn't a List, just Class<? extends Integer>
and Class<?>
, it works as well. But it seems to stop working when the generics is two ore more levels deep. Any reasons/workarounds/etc?