RFR: 8354890: AOT-initialize j.l.i.MethodHandleImpl and inner classes
Ioi Lam
iklam at openjdk.org
Wed Apr 30 21:48:56 UTC 2025
This is a general fix for all the "points to a static field that may hold a different value" failures related to `java/lang/invoke/MethodHandleImpl`. E.g., [JDK-8354840](https://bugs.openjdk.org/browse/JDK-8354840), [JDK-8353330](https://bugs.openjdk.org/browse/JDK-8353330).
AOT-cached method handles quite often refer to the static fields in `MethodHandleImpl` or its inner classes. In the production run, if the value of these static field changes, we may have unexpected behavior related to identity of objects in these static fields. `CDSHeapVerifier` makes a very conservative check for such static fields, but sometimes gives false positives (as in the above two JBS issues)
In this PR, we AOT-initialize `MethodHandleImpl` and its inner classes. This is a more authentic snapshot of the state of `java.lang.invoke` during the assembly phase. We also avoid the need to add and maintain entries in the `cdsHeapVerifier.cpp` table.
I also added more code in `MethodHandleTest.java` to simulate potential usage patterns of `MethodHandle` by the Java core libraries. Hopefully this will reduce the likelihood for innocent core lib changes breaking the AOT assembly phase.
-------------
Commit messages:
- Added more test case to increase coverage on possible core-lib usage patterns for MethodHandles
- Merge branch 'master' into 8354890-aot-init-methodhandleimpl-and-inner-classes
- 8354890: AOT-initialize j.l.i.MethodHandleImpl and inner classes
- @fisk comment -- use proper HeapAccess to load referent; Also refactor AOTReferenceObjSupport::is_enabled()
- Merge branch 'master' into 8354897-soft-weak-references-in-aot-cache
- @fisk offline comments -- tighten up and simplify eligibility check; @DanHeidinga comment -- renamed to MethodType::assemblySetup()
- @DanHeidinga comments
- @fisk comment
- Fixed windows path issues
- Refactored code
- ... and 8 more: https://git.openjdk.org/jdk/compare/1313349a...0f6a2e0a
Changes: https://git.openjdk.org/jdk/pull/24956/files
Webrev: https://webrevs.openjdk.org/?repo=jdk&pr=24956&range=00
Issue: https://bugs.openjdk.org/browse/JDK-8354890
Stats: 176 lines in 7 files changed: 165 ins; 4 del; 7 mod
Patch: https://git.openjdk.org/jdk/pull/24956.diff
Fetch: git fetch https://git.openjdk.org/jdk.git pull/24956/head:pull/24956
PR: https://git.openjdk.org/jdk/pull/24956
More information about the hotspot-dev
mailing list