Notes on implementing concise calls to constructors with type parameters

Alex Buckley Alex.Buckley at Sun.COM
Thu May 14 15:51:16 PDT 2009

Ulf, you ask why:

   Cell<String> cs = new Cell(1); //unchecked warning
   String s = cs.x; //CCE at runtime

cannot be rejected at compile-time, presumably with an error rather than 
a warning on the assignment.

The answer is migration compatibility: it is desirable for new, 
generified code (Cell<String> cs = ...) to be able to call legacy, 
ungenerified code (that returns a raw Cell type).

There is a potential CCE resulting from this call - as indeed there is 
anytime raw types are used by generified code - so the language requires 
a compile-time WARNING when this migration feature is used.

There is no conceivable "upgrade" to this behavior in the JLS.

For the record, this is nothing to do with erasure/reification.


More information about the coin-dev mailing list