RFR: 8355556: JVM crash because archived method handle intrinsics are not restored

Ioi Lam iklam at openjdk.org
Thu Jun 12 02:53:15 UTC 2025


`AOTLinkedClassBulkLoader::finish_loading_javabase_classes()` can execute Java bytecodes (from `<clinit>`). If one of these bytecodes is an AOT-resolved `invokedynamic`, it may be dispatched using an archived method handle intrinsic. Therefore, we should call `SystemDictionary::restore_archived_method_handle_intrinsics()` first to make sure that the method handle intrinsics are ready to be used.

In the JDK mainline, we only execute a very limited set of Java methods which happens to not include any `invokedynamic` bytecodes. That's why this bug has not been found in the mainline.

However, in the Leyden repo, we have other optimizations, such as archived ProtectionDomains, which will cause `invokedynamic` bytecodes to be executed inside `AOTLinkedClassBulkLoader::finish_loading_javabase_classes()`.

Since this is a potential issue even for the JDK mainline, we should fix it (and also backport to JDK 25).

Thanks to @iwanowww for providing the fix!

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

Commit messages:
 - 8355556: JVM crash because archived method handle intrinsics are not restored

Changes: https://git.openjdk.org/jdk/pull/25766/files
  Webrev: https://webrevs.openjdk.org/?repo=jdk&pr=25766&range=00
  Issue: https://bugs.openjdk.org/browse/JDK-8355556
  Stats: 2 lines in 1 file changed: 1 ins; 1 del; 0 mod
  Patch: https://git.openjdk.org/jdk/pull/25766.diff
  Fetch: git fetch https://git.openjdk.org/jdk.git pull/25766/head:pull/25766

PR: https://git.openjdk.org/jdk/pull/25766


More information about the hotspot-runtime-dev mailing list