Idea how to implement VT/VO compatibility in JVM

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


On 01/22/2015 02:34 PM, Vitaly Davidovich wrote:
>
> Ok, so the issue is really reflection/late binding here and not <any 
> T> per say.  In .NET for example, there's reflection support for 
> generics and what one typically does in such a situation is invoke a 
> generic method via reflection by specifying the type parameter 
> reflectively.  This all works because generics are reified in the VM, 
> of course.
>
Well, yes and no: it's related to not being able to instantiate `any T` 
when you don't know `T` at compile-time. Currently you can handle every 
type in Java without having to know it by handling `Object` and every 
primitive. We can't expect people to handle every value type when it's 
an open-ended set, and there's no common superclass of value types, and 
they're not `Object` (unless they're autoboxed which doesn't happen when 
they're in containers like collections). So we can't handle them unless 
you can instantiate their type argument at compile-time. Using `any T` 
on methods only defers the problem but doesn't solve it for blind usages.


More information about the valhalla-dev mailing list