RFR: 8353216: Improve VerifyMethodHandles for method handle linkers [v2]

Dean Long dlong at openjdk.org
Fri Apr 11 22:29:27 UTC 2025


On Sat, 29 Mar 2025 01:22:11 GMT, Vladimir Ivanov <vlivanov at openjdk.org> wrote:

>> Add extra verification logic into `MethodHandle::invokeBasic/linkTo*` to ensure that holder classes are properly initialized.
>> 
>> The patch covers x86 and aarch64 platforms.
>> 
>> There are some differences in expectations between invocation modes.
>> While `invokeStatic` assumes a clinit barrier (and `invokeBasic` just requires the holder class to be fully initialized), other invocation modes can only expect that class initialization has been initiated (due to class initialization failures and premature publication, instances of partially initialized classes can be observed).   
>> 
>> Testing: hs-tier1 - hs-tier4
>
> Vladimir Ivanov has updated the pull request incrementally with two additional commits since the last revision:
> 
>  - assert_different_registers on x86
>  - jcc->jccb

Looks good.

src/hotspot/cpu/aarch64/methodHandles_aarch64.cpp line 110:

> 108:         __ lea(rscratch2, Address(method_holder, InstanceKlass::init_state_offset()));
> 109:         __ ldarb(rscratch2, rscratch2);
> 110:         __ subs(zr, rscratch2, InstanceKlass::fully_initialized);

I think `cmp` might be more readable.

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

Marked as reviewed by dlong (Reviewer).

PR Review: https://git.openjdk.org/jdk/pull/23950#pullrequestreview-2761701536
PR Review Comment: https://git.openjdk.org/jdk/pull/23950#discussion_r2040367922


More information about the hotspot-dev mailing list