Proposal: Improved Wildcard Syntax for Java

Joseph D. Darcy Joe.Darcy at Sun.COM
Tue Mar 17 16:02:58 PDT 2009


Howard Lovatt wrote:
> 2009/3/15 Neal Gafter <neal at gafter.com>:
>   
>> My main concern is that this sounds like a significant change to the
>> type system, and therefore almost certainly out of scope for project
>> Coin.
>>     
>
> There is only one change to the type system; which is to allow
> covariant assignment, e.g. List<Object> lo = new ArrayList<String>().
> This isn't a drastic change, arrays already do this.

This is in general *not* type safe.  Arrays allow one to do this because 
array types are reified and there is a store-check at runtime when 
writing into an array.  Since generics in Java are implemented via 
erasure, this implementation strategy is not possible for Lists and 
Sets, etc.

-Joe



More information about the coin-dev mailing list