unreflectGetter and static class initialization
Remi Forax
forax at univ-mlv.fr
Tue Oct 30 03:10:46 PDT 2012
On 10/30/2012 09:59 AM, Jochen Theodorou wrote:
> Am 29.10.2012 17:29, schrieb Remi Forax:
> [...]
>> In my opinion, the best is to use Unsafe.ensureClassInitialized() the
>> first time you call the BSM, it should be enough.
> That one I did not know so far, interesting. My current work around is
> to go with the fallback internal old MOP path... which means Reflection.
> Now I think Reflection is using that method as well, but my problem is a
> bit that I have no idea about the side effects of that method and its
> availability on other JDKs. Though, maybe it is less an issue for
> invokedynamic, since there are probably not many JDKs that support it.
>
> So in general I try to avoid Unsafe... but maybe it is ok to use here?
As John says, you can use Class.forName(classname, true,
class.getClassLoader())
if Unsafe.ensureClassInitialized doesn't exist.
>
> bye Jochen
>
cheers,
Rémi
More information about the mlvm-dev
mailing list