unreflectGetter and static class initialization

John Rose john.r.rose at oracle.com
Wed Oct 24 12:50:29 PDT 2012


On Oct 24, 2012, at 12:16 PM, Jochen Theodorou wrote:

> while working routing property access in Groovy through invokedynamic I 
> stumbled upon one confusing part... If I have a static field and use 
> Lookup#unreflectGetter to get a handle and then execute that handle, 
> then it seems as if the class containing that field is not initialized. 
> If I first get the field value, it is of course initialized and 
> everything works as it should.
> 
> I have for example a final static field INSTANCE, initialized in cinit 
> with a value. If I use the handle only, then INSTANCE will be null.
> 
> Now... is that really as it should be? Is that a known bug of 
> 1.7.0_06-ea-b10 and fixed in a later version?

Yes, it's a bug, and there is a fix for this integrated into JDK8:
  http://hg.openjdk.java.net/jdk8/jdk8/jdk/log?rev=7023639

(See file DirectMethodHandle.java.)

We are working on backporting this to JDK7.

— John
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://mail.openjdk.java.net/pipermail/mlvm-dev/attachments/20121024/c9f6ee23/attachment.html 


More information about the mlvm-dev mailing list