I think this is a very confusing title, but I don’t know what else to call - probably answered somewhere, but I couldn’t find anything. Take this example:
List<Class<? extends Integer>> myList;
void foo() {
bar(myList);
}
void bar(List<Class<?>> a) { }
He does not compile (not applicable arguments, he says). If I remove the restriction, it works fine:
List<Class<?>> myList;
void foo() {
bar(myList);
}
void bar(List<Class<?>> a) { }
Class<? extends Integer>is more specific than Class<?>. Why does it stop working? Please note that this problem occurs only in second-level generics. If there was no list, simple Class<? extends Integer>and Class<?>, it also works. But it seems that it stops working when generics are two hundred and more levels. Any reasons / workarounds / etc?
source
share