Repository navigation
jvm: Support HotSpot LTS JDK 21 and 25 via VMStructs - #425
Open
mnalmahmud wants to merge 2 commits into
Open
mnalmahmud wants to merge 2 commits into
mnalmahmud wants to merge 2 commits into
Conversation
Parse HotSpot's exported gHotSpotVMStructs and gHotSpotVMTypes metadata tables in lib/jvm.js to resolve Method, ConstMethod, ConstantPool, and InstanceKlass field offsets and AccessFlags/InstanceKlass sizes dynamically across JDK versions, keeping the existing version formulas and vtable disassembly as a fallback when VMStructs symbols are absent. Also handle both 16-bit and 32-bit AccessFlags widths and avoid reading InstanceKlass::_member_names when ResolvedMethodTable is available.
Extend the HotSpot JVM backend to support LTS releases after JDK 17 (JDK 21 and JDK 25): - Update MethodFlags bits (is_old, is_obsolete, and C1/C2/OSR non-compilable flags) on JDK 21+, where JDK-8306851 moved HotSpot's internal method flags out of AccessFlags into Method::_flags. - Treat NMethodSweeper symbols and JVM_Sleep as optional and no-op forceSweep() when the sweeper has been removed (JDK-8290025). - Wrap the zero-argument VM_RedefineClasses::flush_dependent_code() overload used on JDK 21+ when mark_dependent_code() is absent. - Fall back to Abstract_VM_Version::vm_release() when jre_release_version() is absent (JDK 25). - Resolve jni_FindClass directly and widen the instruction scan window to 24 instructions in makeThreadFromJniHelper() so JDK 25's prologue and -Xcheck:jni wrappers are handled reliably.
mnalmahmud
force-pushed
the
jvm-lts-21-25
branch
from
November 20, 2026 17:43
f09c9a8 to
ce1053c
Compare
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Adds HotSpot JVM support for LTS releases after JDK 17 (JDK 21 and JDK 25) by reading HotSpot's own
gHotSpotVMStructs/gHotSpotVMTypesmetadata dynamically across all supported JDKs (8, 11, 17, 21, and 25) with a clean fallback when symbols are stripped.Related PRs (each independent on
main):improve-test-infra) — Test infrastructure & CI (Android API 26–36 + HotSpot JVM runner)clinit-hooking) — Class initializer ($clinit) hookingjvm-lts-21-25) — HotSpot LTS JDK 21 & 25 support viaVMStructs(this PR)Commits
jvm: Read HotSpot struct layouts from VMStructsgHotSpotVMStructsandgHotSpotVMTypes(when exported bylibjvm) to resolveMethod,ConstMethod,ConstantPool,InstanceKlass(vtable offset viasizeof(InstanceKlass)), andAccessFlagssize dynamically across JDK 8–25, falling back to hardcoded offsets if stripped.readAccessFlags()/writeAccessFlags()to handle both 16-bit (u2, JDK 25 / JDK-8347147) and 32-bit (u4, JDK 8–24)AccessFlags.ConstMethod::_adapter(stackmapDataOffset + pointerSize) on JDK 9–16 when neitherMethod::_adapternorConstMethod::_adapteris exported ingHotSpotVMStructs.jvm: Support HotSpot JDK 21 and 25MethodFlagsbits (is_old,is_obsolete,is_not_c1_compilable,is_not_c2_compilable,is_not_c2_osr_compilable) inMethod::_flagson JDK 21+ (JDK-8306851), restoring them on revert.NMethodSweeper::*andJVM_Sleepas optional and no-opforceSweep()when the sweeper has been removed (JDK-8290025).VM_RedefineClasses::flush_dependent_code()overload used on JDK 21+ whenmark_dependent_code()is absent.Abstract_VM_Version::vm_release()whenjre_release_version()is absent (JDK 25).jni_FindClassdirectly and widen the instruction scan window to 24 instructions inmakeThreadFromJniHelper()to handle JDK 25's prologue and-Xcheck:jniwrappers.Verification
ClassInitializerTestfrom feat: Add support for hooking class initializers ($clinit) #424 across Android API 26–36 and Temurin JDK 8, 11, 17, 21, and 25 (both interpreter and JIT/AOT modes — 16/16 passed): https://github.com/mnalmahmud/frida-java-bridge/actions/runs/44783079156npm run lint,node --check index.js lib/*.js, andtsc --noEmit --lib es2022 index.d.ts.