[MVT] value type and getClass()

Maurizio Cimadamore maurizio.cimadamore at oracle.com
Sat Aug 5 07:23:19 UTC 2017



On 04/08/17 23:55, forax at univ-mlv.fr wrote:
>
> ----- Mail original -----
>> De: "Maurizio Cimadamore" <maurizio.cimadamore at oracle.com>
>> À: "Remi Forax" <forax at univ-mlv.fr>, "valhalla-dev" <valhalla-dev at openjdk.java.net>
>> Envoyé: Samedi 5 Août 2017 07:23:16
>> Objet: Re: [MVT] value type and getClass()
>> I'll have to try, but I don't think it will work w/o boxing (no methods
>> on the value). That said, getClass() might be special enough that it
>> might accidentally work. It will defo stop working once the verifier
>> kicks in though.
> getClass() on a value type should work without boxing given that the semantics is well defined and getClass() is not defined in term of bytecode so not need to box or to wait a type QObject;
> (that said, i think i need getClass() on __Value :( )
Can you expand a bit more on what is your need? I thought you were 
speaking bytecode, but now I think you were asking about the source 
code. To get the class of __Value (assuming that's what you need), you 
can use the same trick as here:

http://hg.openjdk.java.net/valhalla/valhalla/jdk/file/tip/src/java.base/share/classes/valhalla/shady/MinimalValueTypes_1_0.java#l214

[basically you have to 'switch off' the static type system, or you won't 
be able to assign it to Class<?> because of the val vs. ref mismatch]

Maurizio
>
> Rémi
>
>> In any case, thanks for pointing that out, I'll double check this.
>>
>> Maurizio
>>
>>
>> On 04/08/17 20:09, Remi Forax wrote:
>>> Hi,
>>> Does a getClass() on a value type works with the MVT ?
>>>
>>> Rémi




More information about the valhalla-dev mailing list