Question about get Method Handle to interface field
Maurizio Cimadamore
maurizio.cimadamore at oracle.com
Tue Sep 5 08:25:45 UTC 2017
On 02/09/17 20:26, Remi Forax wrote:
> Hi Radek,
> Do you still trying to implement properties in Java ?
>
> It seem to be an overlook to me,
> getstatic and putstatic are allowed on a static field declared in an interface, getstatic and putstatic use a CONSTANT_Fieldref so unlike constant method handle based on method which need to know if the owner is an interface or not (to generate a CONSTANT_Methodref or a CONSTANT_InterfaceMethodRef), see JVMS 4.4.2.
>
> The following patch should fix the issue
> case ClassFile.REF_getStatic:
> case ClassFile.REF_putStatic:
> staticOk = true;
> + interfaceOwner = true;
> case ClassFile.REF_getField:
>
> Rémi
That's right - that code is buggy and does not handle field handles
correctly, mostly because does not need them. Anyway, if you come up
with a patch which works for your use case, I'd be happy to take a look.
What Remi suggests seems sensible, although I have a feeling that this
logic could be simplified a little.
Maurizio
>
> ----- Mail original -----
>> De: "Radek Smogura" <rsmogura at gmail.com>
>> À: compiler-dev at openjdk.java.net
>> Envoyé: Samedi 2 Septembre 2017 19:20:06
>> Objet: Question about get Method Handle to interface field
>> Hi all,
>>
>> Recently I played a little bit and tried to obtain MethodHandle to GET method
>> for interface static field. The code which I try to use is
>>
>> new Pool.MethodHandle(ClassFile.REF_getStatic, sym, types);
>>
>> But it fails on assertion: Assert.check(!refSym.owner.isInterface() ||
>> interfaceOwner) located in MethodHandle.checkConsistent:365 ?
>>
>> I wonder if such handles are allowed?
>>
>> Thanks,
>> Radek
>>
>> P.S. Sorry if I post this message twice, but I got SMTP issues
More information about the compiler-dev
mailing list