I cannot explain why the compiler won't treat these as equivalent, but given that it does not, I'll attempt to explain why it refuses to do so.
The first one (List<? extends Object>
) asserts that the type of objects held in the List
are of some unknown type derived from Object
. The second one (List<?>
) says less; it merely says that the type of the objects in the list is unknown. It doesn't mention any expected supertype as the upper bound of the unknown type.
In order to verify the first assumption, the compiler wants to hear you say something about the expected types held in the List
instance constructed here as the raw type LinkedList
, which says nothing on the subject. However, if you were to construct the instance as type LinkedList<Object>
, you're at least guaranteeing that covariant reads against the instance will be consistent with your assertion: namely, that the things in this list are some kind of Object
.
Now, this all seems silly, because every reference/non-primitive type in Java extends Object
, so there shouldn't be any difference in interpretation between List<? extends Object>
and List<?>
; after all, the second one implies the first one, by virtue of the language's type system's mandated singly-rooted class hierarchy.