Skip to content

feat(android): link native declarations to static JNI candidates - #7472

Merged
gensokyo-dev merged 5 commits into
mainfrom
feat/android-jni-bindings
Oct 27, 2026
Merged

gensokyo-dev merged 5 commits into
mainfrom
feat/android-jni-bindings

Conversation

@gensokyo-dev

@gensokyo-dev gensokyo-dev commented Oct 27, 2026 •

Copy link
Copy Markdown
Collaborator

Summary

Fixes #6403. Find static JNI implementation candidates for original DEX native declarations, per ABI and exact APK library occurrence, including libraries that expose only JNI_OnLoad. Class selection preserves global registration-pair ambiguity. Compact replies retain full Evidence and explain unsupported or incomplete scans.

Contract and scope

  • Adds named inspect_android_jni_bindings (MCP defaults to retained summary) and matching inspect-android-jni-bindings CLI through the existing Android workflow. Exact class/method/descriptor/ABI/library selection, stable IDs, batch ID lookup, fields and retained pages share one implementation.
  • The existing JAR's raw DEX reader preserves declarations before JADX deduplication; JNI queries skip APK loading into the decompiler. One shared sparse ELF relocation owner supports REL/RELA/RELR; the existing IL2CPP consumer now uses it. Table candidates retain all three slots, relocation sources, function/code addresses and file offsets.
  • matched means observed candidate presence. Separate coverage prevents partial scans from claiming uniqueness or absence; table classes remain ambiguous/unknown unless the complete global inventory establishes attribution. Summary includes no-edge library failure reasons and selected native declarations even without ABI rows. Parsed checkpoints survive final cleanup failure/cancellation; exact resource leases gate retry.
  • The immutable APK session reuses complete declarations and one selected library scan. Fresh admission validates caller bytes; idle/close releases caches. Bounds cover preallocation, scan work, retained facts and serialized delivery.
  • Static read-only contribution within the existing provider; maintainer scope decision: not applicable. Launches only the owned analysis JVM and writes private snapshots/explicit Evidence outputs. No target execution, injection, mutation or protection recovery. Bridge 9 uses the unchanged supplied JADX 0.7.1 JAR. No dependency/installer changes or committed binaries/generated outputs.

Executed validation

  • Type/lint/build and 396 exact tests pass, including actual ZIP cleanup/retry/cancellation, native projection/parsing, existing session behavior, public contracts and IL2CPP regressions. Latest-main input/contract cases and 16 artifact-aware SDK schema tests pass without relaxing assertions.
  • Full actual JDK21/JADX metadata and downstream CLI/MCP parity pass, including native reads before any APK load, CRC/duplicate/malformed DEX, raw identities and cross-DEX direct invokes.
  • Genuine NDK r27d fixtures: ordinary REL/RELA, RELR and APS2 across four ABIs, overloads, UTF-16/MUTF-8, duplicate classes/libraries and partial coverage. Independent source/javac-header/readelf/byte oracles validate 25 built libraries and 33 golden table entries.
  • 371 real SDK calls and eleven CLI parity checks pass. Conscrypt 2.8.0 original library bytes resolve EVP_PKEY_new_RSA to arm64 0xfa11c with the exact three relocated slots. Complete/summary facts match. Owned-copy removal leaves retained summaries, selected slots, pages and full parent exports readable; originals remain unchanged.
  • Review corrections pass type/lint/build and 330 cases in 13 related files, plus all 38 JNI cases after adding cancellation during GNU version decoding. The shared decoder streams IL2CPP writes without lowering file-backed capacity; GNU version traversal/cache work is bounded and cooperative; JNI string-limit exhaustion remains partial/unknown. Optional Conscrypt qualification stays optional and rejects missing advertised artifacts. Final built 25-library oracles and fresh real SDK/CLI qualification pass. These test counts overlap earlier gates; documentation/check/render results are recorded in the report.

Reproduction, artifact/revision pins, all costs and failed attempts. Equivalent Conscrypt complete/summary tasks include catalog, arguments, 12 pages and proof export: warm text estimates fall from ~225k to ~32k (about 86%), with the same fact digest. Cold/warm, startup, qualification, CLI, CPU and family-RSS costs are reported separately. No equivalent pre-feature table workflow, actual model-billing result or general latency/memory speedup is claimed.

Limits: Linux/JDK21/JADX0.7.1 qualified. Cross-ABI static ELF fixtures do not establish Windows/macOS lifecycle or runtime Android behavior. The Conscrypt APK is a static derivative, not an installed vendor app. Runtime-built tables, obfuscated strings and unavailable split/runtime code remain unknown. Empty-ABI coverage is a domain regression, not a separate real SDK artifact claim. The shared IL2CPP path has existing regressions, without a new real IL2CPP-app qualification.

Author readiness

Human owner: @gensokyo-dev

  • I reviewed the final diff and relevant existing code, understand the change and its edge cases, and take responsibility for the complete PR, including AI-assisted work.
  • I checked the evidence above, confirmed it supports the current change, and recorded meaningful validation gaps.
  • I declare this PR ready for initial maintainer review.

@chatgpt-codex-connector

Copy link
Copy Markdown

Codex Review Summary

This comment shows the latest Codex review activity on this pull request.

Review Status Commit Review trigger
📝 Code Review ⚠️ Failed 2026-10-27T09:43:43.621502Z
We couldn’t complete this review. Comment @codex review to try again.
106b67f PR opened
ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review" or "@codex security review".

Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings.

@chatgpt-codex-connector

Copy link
Copy Markdown

Codex usage limits have been reached for code reviews. Please check with the admins of this repo to increase the limits by adding credits.
Repo admins can enable using credits for code reviews in their settings.

@greptile-apps

greptile-apps Bot commented Oct 27, 2026 •

Copy link
Copy Markdown
Contributor

RetriggerView in GreptileConfidence Score: 5/5 Tier: plus

[High impact] The reviewed changes appear safe to merge; all four previous findings are addressed.

Summary

Adds static links between original DEX native declarations and JNI candidates, grouped by ABI and exact APK library occurrence.

  • Android reports connect native declarations to static library candidates.
  • Android and IL2CPP analysis share ELF pointer relocation reading.

Validation was source-only; tests were not rerun. Supersession could not be checked because GitHub authentication was unavailable.

Diagram

%%{init: {'theme': 'neutral'}}%%
flowchart TD
  APK[Immutable APK] --> DEX[Original native declarations]
  APK --> ELF[Selected library occurrences]
  ELF --> Exports[JNI exports]
  ELF --> Relocations[Shared relocation reader]
  Relocations --> Tables[Static table candidates]
  DEX --> Join[Global attribution and selected bindings]
  Exports --> Join
  Tables --> Join
  Join --> Evidence[Complete retained Evidence]
  Evidence --> Summary[Summary]
  Evidence --> Pages[Selected fields and pages]
  Relocations --> IL2CPP[Stream writes into private IL2CPP copy]
Loading

Reviews (3) · Last reviewed commit: "fix(android): bound JNI parsing and pres..." · Reviewed by Greptile

Comment thread src/native/android/AndroidJniLibrary.ts Resolved
Comment thread src/native/android/AndroidJniLibrary.ts Resolved
@gensokyo-dev

Copy link
Copy Markdown
Collaborator Author

Final-head CI/review audit for 69beb1891670f8c79b2846465187d0a3a4e11796:

  • CI run 40490194638 actually checked out merge 3996452542d3806e3b28f9b79ba17541c61062ba with main parent d6f88becd, confirmed in classify and build logs.
  • Audited all eight failed/cancelled shard logs, source tests and portable/required aggregates. All 89 observed failure identities and multiplicities reproduce on a pristine checkout of that exact main parent; unmatched: zero. The aggregate portable report contains only a subset of cancelled shards' observed failures, so it was not used as the complete inventory.
  • All 22 exposed diagnostic headings match. The two newly observed cleanup/retry assertion blocks also match after substituting only their recorded generated fixture roots. The other 67 progress-only failures do not expose their detailed CI mechanism; that remains unknown. Cancelled, unexecuted coverage is not counted as passing.
  • The two additional main controls are processCleanupRetryOwnership.test.ts: “keeps mixed root errors and retry aggregates bound to only unresolved roots” and “blocks scope admission on owner-bound retry failure and resumes after release”. Both fail on pristine main at the same assertions (171:43 and 291:43), expecting temporary_root but receiving the actual fixture path. These are outside this diff.
  • Final build, static checks, documentation and Greptile pass. All four actionable review findings have fixes and executed regression evidence in their resolved threads. Local relevant validation passes 330 cases across 13 files, plus the final 38-case JNI/cancellation gate; independent real-library and actual SDK/CLI qualification pass. Pinned verification report.

No PR-specific CI failure was established. The repository owner's explicit authorization covers admin bypass for reproduced main failures and the Author readiness gate; the human declarations remain unchecked.

@gensokyo-dev
gensokyo-dev merged commit 570abe9 into main Oct 27, 2026
33 of 47 checks passed
@gensokyo-dev
gensokyo-dev deleted the feat/android-jni-bindings branch October 27, 2026 10:53
kayodeshodeinde2-beep pushed a commit to kayodeshodeinde2-beep/rea that referenced this pull request Nov 10, 2026
@morluto morluto mentioned this pull request Nov 11, 2026
3 tasks done
kayodeshodeinde2-beep pushed a commit to kayodeshodeinde2-beep/rea that referenced this pull request Nov 16, 2026
kayodeshodeinde2-beep pushed a commit to kayodeshodeinde2-beep/rea that referenced this pull request Nov 18, 2026
@morluto morluto added area: native Native analysis and decompilation, including Ghidra, IDA, and Hopper analysis behavior enhancement New feature or request labels Nov 23, 2026
kayodeshodeinde2-beep pushed a commit to kayodeshodeinde2-beep/rea that referenced this pull request Nov 23, 2026
kayodeshodeinde2-beep pushed a commit to kayodeshodeinde2-beep/rea that referenced this pull request Nov 27, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

area: native Native analysis and decompilation, including Ghidra, IDA, and Hopper analysis behavior enhancement New feature or request

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[Feature] Link Android native methods to their JNI implementations (Java_* exports and RegisterNatives tables)

2 participants