RFR: 8351748: Classes of method handles in AOT cache should be AOT-inited

Vladimir Ivanov vlivanov at openjdk.org
Wed Mar 12 17:19:12 UTC 2025


On Wed, 12 Mar 2025 04:09:24 GMT, Ioi Lam <iklam at openjdk.org> wrote:

> Whenever we store a MethodHandle in the AOT cache, we need to make sure that the class of this method is aot-initialized. Otherwise, the JVM might execute a BSM without first initializing the class of this BSM.
> 
> Please see the bug report for detail analysis.
> 
> I also fixed a problem in related logging code.

Proposed fix only covers Java methods. But there are Java field accessors which can be exposed either as MethodHandles or Varhandles.

src/hotspot/share/cds/heapShared.cpp line 342:

> 340:         Method* m = java_lang_invoke_ResolvedMethodName::vmtarget(obj);
> 341:         if (m != nullptr) {
> 342:           InstanceKlass* method_holder = m->method_holder();

Should you check first that the holder is already initialized before adding it to the list of AOT-inited classes?

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

PR Review: https://git.openjdk.org/jdk/pull/24004#pullrequestreview-2679279676
PR Review Comment: https://git.openjdk.org/jdk/pull/24004#discussion_r1991949260


More information about the hotspot-runtime-dev mailing list