On Tue, 16 Jun 2026 18:17:10 GMT, Chen Liang <[email protected]> wrote:

>> The checks for strict statics for VarHandle was never implemented. Luckily 
>> we can reuse LazyInitializingVarHandle so the patch is not too complex.
>> 
>> ---------
>> - [x] I confirm that I make this contribution in accordance with the 
>> [OpenJDK Interim AI Policy](https://openjdk.org/legal/ai).
>
> Chen Liang has updated the pull request with a new target base due to a merge 
> or a rebase. The incremental webrev excludes the unrelated changes brought in 
> by the merge/rebase. The pull request contains three additional commits since 
> the last revision:
> 
>  - Restrict write access for IMPL_LOOKUP VH on strict final
>  - Merge branch 'lworld' of https://github.com/openjdk/valhalla into 
> fix/lw-strict-static-vh
>  - Missing strict static validation for VarHandle

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.

src/java.base/share/classes/java/lang/invoke/MethodHandles.java line 3964:

> 3962:             }
> 3963:             return VarHandles.makeFieldHandle(getField, refc,
> 3964:                                               this.allowedModes == 
> TRUSTED);

Is this no longer needed? Are all trusted final fields strict init now?

-------------

PR Review Comment: 
https://git.openjdk.org/valhalla/pull/2550#discussion_r3423417849
PR Review Comment: 
https://git.openjdk.org/valhalla/pull/2550#discussion_r3423345589

Reply via email to