On Tue, 16 Jun 2026 22:39:57 GMT, Chen Liang <[email protected]> wrote:
>> src/java.base/share/classes/java/lang/invoke/LazyInitializingVarHandle.java
>> line 72:
>>
>>> 70: VarHandle target() {
>>> 71: ensureInitialized();
>>> 72: return target;
>>
>> What about static method access? `onStaticFieldAccess` seems to be only used
>> for field access, and the regular access to the target seems to skip the
>> `ensureInitialized` check now.
>
> `target` is completely eliminated now. `IndirectVarHandle` uses `asDirect`
> before passing a VH to the implementation MH; `LazyInitializingVarHandle`
> uses `onStaticFieldAccess` or old `target` once you are within the
> implementation MH/MemberName, so the two mechanisms were quite different and
> better separated. All other VHs don't need this class initialization barrier.
Sorry, I'm confusing myself. More generally: I'm wondering what happens if some
code calls `getTarget` directly now. Maybe it's better to leave the method
overridden and throw an exception, since `onStaticFieldAccess` should be called
now.
-------------
PR Review Comment:
https://git.openjdk.org/valhalla/pull/2550#discussion_r3428014974