Idea how to implement VT/VO compatibility in JVM

Stéphane Épardaud stef at epardaud.fr
Thu Jan 22 13:36:10 UTC 2015


On 01/22/2015 02:21 PM, Maurizio Cimadamore wrote:
> Object o = new ArrayList<Point>();
>
> where Point is a value class.
>
> Now,
>
> o instanceof ArrayList<Point> //?
>
> Or, as translated by our current prototype:
>
> o instanceof ArrayList${0=QPoint;} //yes!
And that's good!
> But how about:
>
> o instanceof ArrayList<?> //?
Yes, because it would be also an `instanceof ArrayList<Object>` with my 
proposal. I know at runtime we end up with two separate classes for 
`ArrayList<Object>` and `ArrayList<Point>`, but if `ArrayList<Point>` 
has all the bridge methods to satisfy `ArrayList<Object>` we can make 
`instanceof ArrayList<?>` return true for any instance of `ArrayList` 
regardless of value type arguments. So yeah, I agree it's not entirely 
limited to compiler support and we need some support from the VM, but 
that's already the case since we expect specialisation to be handled by 
the VM to generate pseudo-classes.

BTW, aren't you afraid of the proliferation of specialised classes at 
runtime for the VM? I know PermGen moved away, but still, classes are 
expensive to load…


More information about the valhalla-dev mailing list