Simplifying reified generics with partial specialization

Ron Pressler ron at paralleluniverse.co
Mon Jan 5 17:37:06 UTC 2015


A specialized class does not extend its "template" (i.e. ArrayList<int>
doesn't extend ArrayList) but still implement its interfaces.

As to your other example, you'd get a
ClassCastException/ArrayStoreException because the storage is still
specialized. This behavior is specifically allowed by the List interface
contract.

Ron Pressler
paralleluniverse.co
@puniverseco <https://twitter.com/puniverseco> on Twitter

On Mon, Jan 5, 2015 at 5:41 PM, Simon Ochsenreither <simon at ochsenreither.de>
wrote:

> > Why, you'd get an NPE, of course! While ArrayList<int> would be a
> List<Integer>, it will *not* be an ArrayList<Integer>.
>
> That sounds incredibly asymmetric. What's the rule behind "it implements
> X, but not Y"?
>
>
> What about the second, more interesting case I mentioned?
>


More information about the valhalla-dev mailing list