Idea how to implement VT/VO compatibility in JVM

Vitaly Davidovich vitalyd at
Thu Jan 22 13:56:08 UTC 2015

You don't need to box anything if the generic method takes Collection <any
T> - you just call it once you've obtained the type parameter.  If you've
already boxed the value type you may as well call methods taking Object.
The side benefit to this is you don't need to box the items in the

sent from my phone
On Jan 22, 2015 8:52 AM, "Stéphane Épardaud" <stef at> wrote:

> On 01/22/2015 02:46 PM, Vitaly Davidovich wrote:
>> Yes, but I'm not proposing to handle every value type (which is
>> impossible anyway since you don't know the set). Instead, what would be
>> nice is to allow calling <any T> methods at runtime by providing the T
>> parameter at that point, after getting it via reflection.  This requires
>> some form of reification/VM support though.
>>  Well, if I understand it correctly, value type arguments will be reified
> necessarily because they end up specialising the type they parameterise. So
> given a `List<Date>` instance you would get a `List${0=QDate;}` class, from
> which it _must surely_ be possible to extract the `Date` type argument at
> runtime via reflection. So while that information is lost in an instance of
> `List<Object>` (erasure), it should not be erased from instances of generic
> types whose type arguments are value types.
> So yeah, that's an option, but it would _still_ require autoboxing of any
> value type you put in or extract via reflection. And be less elegant
> because it forces you to use reflection for every method invocation of
> `Collection<val ?>`.

More information about the valhalla-dev mailing list