unreflectGetter and static class initialization

Remi Forax forax at univ-mlv.fr
Mon Oct 29 10:13:52 PDT 2012


On 10/29/2012 05:45 PM, Julien Ponge wrote:
> I once heard that there might me plans to push Unsafe to the public APIs... Does anybody have informations about this?

sun.misc.Unsafe is already supported by a lot of Java compatible (or 
not) environment,
so it's a kind of de facto standard.

Now, I like the fact that you have to do some magic to access to the 
Unsafe instance,
to don't forget that using killing curses is a good way to visit Azkaban.

> - Julien

Rémi

>
> Le 29 oct. 2012 à 17:29, Remi Forax <forax at univ-mlv.fr> a écrit :
>
>> On 10/29/2012 05:03 PM, Christian Thalinger wrote:
>>> On Oct 24, 2012, at 3:32 PM, John Rose <john.r.rose at oracle.com
>>> <mailto:john.r.rose at oracle.com>> wrote:
>>>
>>>> On Oct 24, 2012, at 1:08 PM, Jochen Theodorou wrote:
>>>>
>>>>> what do you suggest as workaround?
>>>> You could force the class to be initialized when the MH is created.
>>>> This can be done with Class.forName.  It would not exactly give you
>>>> the semantics you want, since the init would happen early.
>>>>
>>>> Or, you could wrap the buggy MH in a MH which first forces
>>>> initialization.  With a switchpoint you can make it a once-only event
>>>> (per thread, at least).
>>> ...or move to JDK 8 until 7u with an updated 292 is released.  Doesn't
>>> the NoClassDefFoundError bite you anyway?
>>>
>>> -- Chris
>> I'm sure that Jochen will be happy to move to jdk8 but I'm also sure
>> that all Groovy users will not be happy to do the same :)
>>
>> In my opinion, the best is to use Unsafe.ensureClassInitialized() the
>> first time you call the BSM, it should be enough.
>>
>> Rémi
>>
>> _______________________________________________
>> mlvm-dev mailing list
>> mlvm-dev at openjdk.java.net
>> http://mail.openjdk.java.net/mailman/listinfo/mlvm-dev
> _______________________________________________
> mlvm-dev mailing list
> mlvm-dev at openjdk.java.net
> http://mail.openjdk.java.net/mailman/listinfo/mlvm-dev



More information about the mlvm-dev mailing list