Skip to content

fix(android)!: preserve JVM settings and reuse metadata sessions - #908

Merged
morluto merged 2 commits into
mainfrom
codex/android-performance-893
Oct 7, 2026
Merged

morluto merged 2 commits into
mainfrom
codex/android-performance-893

Conversation

@morluto

@morluto morluto commented Oct 7, 2026

Copy link
Copy Markdown
Owner

Summary

Android inspection now preserves caller JVM settings, reuses an owned session, and reads class metadata without decompiling application source. Graph traversal avoids repeated edge scans and adjacency copies.

Fixes #901. Refs #893. The reproduced upstream metadata defect is tracked in jadx-headless-mcp#39.

Problem and expected behavior

REA forced a 512 MiB heap and one visible CPU, overriding caller settings and constraining JVM ergonomics. Each operation started another JVM. A class metadata request also reached upstream getters that trigger source generation. Metadata inspection should preserve the caller's configuration and leave class bodies unloaded; related requests should safely reuse the admitted APK.

Change and scope

  • Launch with standard JVM environment precedence; add heap/processor flags only for explicit REA configuration. Keep the single JADX worker independent of JVM CPU visibility.
  • Serialize requests through one immutable, digest-verified session. Retire it on target/configuration changes, idle expiry, failure, cancellation, disconnect, or shutdown, and join owned cleanup.
  • Package a REA-owned Java source bridge around the unchanged upstream JAR. Read parsed metadata directly, freeze member identities, retain generic types, select overloads by exact identity, and paginate indexed class names.
  • Reset retained captures between operations while preserving per-operation output bounds and request-local Evidence.
  • Append JavaScript adjacency entries and index native edges once per traversal direction.

The OpenJDK investigation found expected option precedence and GC ergonomics; it did not establish a JVM defect warranting an OpenJDK patch.

Contract and boundary impact

  • Semantic owner and earliest changed stage: Android launch configuration and provider admission; graph adjacency construction remains in the domain.
  • CLI and MCP/tool-catalog contract: existing Android tools share the same implementation; descriptions disclose parsed-member coverage and lifecycle. Effective runtime settings appear in evidence.
  • Provider, bridge, target-format, or platform compatibility: audited JADX MCP 0.7.1 JAR stays unchanged. The packaged bridge requires a full JDK 17+ with its compiler module.
  • Evidence, artifact, provenance, or reconstruction contract: APK, engine, and bridge identities are verified; aliases and overload identities remain stable; incomplete or ambiguous results retain explicit limitations.
  • Process execution, authorization, cleanup, or containment impact: one owned serialized JVM, bounded operation output, joined cancellation/shutdown; uncertain cleanup blocks replacement and preserves its workspace.
  • Generated metadata, package, or installation impact: canonical descriptions and generated catalogs are updated; package includes bridge source. No dependency or toolchain installation is added.

Evidence and regression coverage

  • Tests cover configuration precedence, session reuse/retirement, immutable request evidence, queued and active cancellation, cleanup failures, output bounds, malformed protocol, overload selection, and graph semantics.
  • Real-JAR regression proves all 5,700 public-fixture classes remain NOT_LOADED after metadata inspection; generic types and three real overload bodies remain correct after generation.
  • On macOS arm64/JDK 21, public ApiDemos cold class inspection median fell from 9,683 to 1,587 ms (three samples). Warm operations took approximately 30–39 ms, and 15 related operations used one JVM. Baseline forced 512 MiB/one CPU; new defaults used normal JVM ergonomics, so this measures the combined change.
  • Synthetic function benchmarks: 16,000-edge JavaScript star, 189.22 → 4.67 ms; native 50,000 edges/1,500 reachable nodes, 414.04 → 5.38 ms. These are internal traversal measurements. Results matched the base in 360 JavaScript and 720 native randomized comparisons.
  • Representative real CLI evidence excerpt with caller JAVA_TOOL_OPTIONS=-Xmx8g:
{"engine":{"name":"jadx-headless-mcp","version":"0.7.1","worker_count":1,"heap_limit_mib":8192}}
  • Remaining proof gaps: the reporter's private 133 MB/11-DEX APK, Linux, and JDK 25 remain unverified. Public-fixture success does not prove its load-time OOM is resolved.

  • Observed, derived, and inferred claims remain distinguishable.

  • Artifact identity, source provenance, and failed attempts remain preserved.

  • Unsupported, incomplete, unavailable, or uncertain outcomes remain visible.

Validation performed

  • npm run check:fast — typecheck and lint passed after rebasing onto current main.
  • npm run test:focused -- <11 affected test files> — 75 passed; one host-dependent firmware test skipped.
  • npm run docs:generate and npm run docs:check — generated metadata aligned with current main and passed.
  • git diff --check origin/main...HEAD — passed.
  • npm run verify:android with OpenJDK 21, audited JAR, and public ApiDemos APK — real CLI/MCP, metadata, and cancellation checks passed after rebase.
  • Before rebase, npm pack artifact ran all five Android CLI/MCP operations, metadata regression, and SIGTERM cleanup successfully, with repository-installed dependencies linked into the extracted package.

Compatibility, safety, and release

  • Breaking change: configure a full JDK 17+ rather than a runtime-only Java installation. The PR title marks this release impact.
  • Real provider/OS coverage: macOS arm64 and OpenJDK 21; no real Hopper, Ghidra, IDA, or browser verification was performed for this change.
  • Package impact: Java bridge source is shipped; APKs, JARs, generated binaries, and local profiling artifacts are excluded.
  • Review: repeated independent lifecycle and Java metadata reviews finished without actionable findings. Caller evidence is retained, transport credentials remain protected, and the ambient environment is not persisted.

Review checklist

  • The PR has one focused outcome and a Conventional Commit title.
  • Related issues are linked.
  • Tests cover changed observable behavior and meaningful failure paths.
  • Owning docs, contracts, and generated metadata are updated.
  • User-visible CLI/MCP changes include representative output.
  • Final diff checked for secrets, unrelated cleanup, and unsupported claims.

Read class metadata without generating application source, retain immutable serialized APK sessions, and join owned cleanup on cancellation and shutdown.

BREAKING CHANGE: Android analysis now requires a full JDK 17 or newer with its compiler module for the packaged Java source bridge.
@chatgpt-codex-connector

chatgpt-codex-connector Bot commented Oct 7, 2026 •

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 ✅ Completed 2026-10-07T08:49:30.868539Z 98f8e29 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.

@morluto
morluto merged commit eab34a9 into main Oct 7, 2026
27 checks passed
@morluto
morluto deleted the codex/android-performance-893 branch October 7, 2026 08:50
darsrc pushed a commit to darsrc/rea that referenced this pull request Oct 10, 2026
…luto#908)

* perf(graph): avoid repeated traversal edge scans and copies

* fix(android)!: preserve JVM settings and reuse metadata sessions

Read class metadata without generating application source, retain immutable serialized APK sessions, and join owned cleanup on cancellation and shutdown.

BREAKING CHANGE: Android analysis now requires a full JDK 17 or newer with its compiler module for the packaged Java source bridge.
@morluto morluto added the bug Something isn't working label Oct 14, 2026
@morluto morluto added the area: runtime Process capture and runtime observation label Nov 26, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

area: runtime Process capture and runtime observation bug Something isn't working

Projects

None yet

Development

Successfully merging this pull request may close these issues.

fix(android): avoid eager JADX code generation and retain owned APK sessions

1 participant