[jboss-dev] Does this seem like a compiler bug?

Scott M Stark sstark at redhat.com
Wed Nov 21 13:46:55 EST 2007


By validating whether the parameter is used in any assignment
expressions in the class. I don't see how the Collection<Class> to a
Collection<Object> comparison is the same. This has a completely
different erasure for the collection element, where as Class<?> and
Class have the same erasure.

David M. Lloyd wrote:

> How would the compiler know that the parameter may be used for mutable
> operations?  There's no way it could differentiate between the two
> cases.
> 
> The "?" is treated differently from an unqualified type because an
> unqualified List can allow you to add any Object type, whereas "?"
> means there is *some* specific type required but you don't know what it
> is; therefore it is unsafe to make any assumptions regarding what can
> be accepted.  This fails to compile for the same reason that casting
> from a Collection<Class> to a Collection<Object> fails.  The compiler
> can't tell how you intend to make use of the parameter.
> 
> I think this is an Eclipse bug, not a JDK bug.
> 
> - DML




More information about the jboss-development mailing list