List<?> is not equivalent to List<? extends Object>
forax at univ-mlv.fr
Mon Apr 21 06:54:01 PDT 2008
the JLS currently considers that List<? extends Object> is not
equivalent to List<?>.
List<?> is reified but not List<? extends Object> so they behave
It's not a big problem in general, if you want a List<?>, you declare a
But (there is always a but), when the compiler infers a type argument
it's more problematic, by example,
HashSet<Class<?>> constantClassSet=new HashSet<Class<?>>();
emits a warning because the second line creates an array of
Class<? extends Object> which is not safe.
I think it's stupid, i propose to modify section 18.104.22.168 (JLS3) to
add a line saying that if an inferred type argument is Type<? extends Bound>
with Bound the bound of the type varaible of Type, it is inferred Type<?>.
More information about the compiler-dev