On Jun 3, 2020, at 5:16 PM, Paul Sandoz <[email protected]> wrote:
>
> if (UNSAFE.shouldBeInitialized(cls)) {
> UNSAFE.ensureClassInitialized(cls);
> }
>
> Although it seems redundant to perform the check, suggesting it is not needed.
It’s useful (IIRC) in this kind of code:
MethodHandle mh = … something about cls ...;
if (!UNSAFE.shouldBeInitialized(cls))
return mh;
// Oops, every eventual call to mh needs to do the check:
return filterArguments(mh, 0, UNSAFE_ensureClassInitialized.bindTo(cls));