Skip to content

fix(lifecycle): own Java debug JVMs and reject missing results - #343

Closed
Ajaymamtora wants to merge 2 commits into
rcasia:mainfrom
Ajaymamtora:fix/java-invocation-lifecycle
Closed

Ajaymamtora wants to merge 2 commits into
rcasia:mainfrom
Ajaymamtora:fix/java-invocation-lifecycle

Conversation

@Ajaymamtora

Copy link
Copy Markdown

Summary

Closes #342.

  • Await the real JDTLS java/buildWorkspace protocol (boolean request, numeric status); propagate exceptions and explicit compiler failure before classpath resolution/JVM launch. Preserve documented nil-returning legacy synchronous compilers.
  • Retain an invocation-owned vim.system handle. Bound JDWP readiness, post-debug exit/report waits and shutdown; detect split stdout/stderr banners and early exits. Add targeted, idempotent TERM/KILL, startup-abandonment and editor-exit cleanup without creating another JDTLS/debugger manager.
  • Reserve unique report directories atomically. Missing/empty/partial selected-test reports and cancelled/failed infrastructure now produce truthful failures rather than inferred success/skip. Clean only invocation-owned reports.
  • Use existing Neotest DAP hooks to claim/settle/stop the JVM. Cleanup supports both synchronous and async hook callers. Check Java DAP registration before spawning a suspended JVM.

Compatibility

launch_debug_test still returns wait()/is_set() termination operations, now bounded, with additional wait_ready, wait_exit, stop, claim and structured state. Injectable job runners must return the process handle from start() for cancellation support. Optional debug_startup_timeout_ms, debug_exit_timeout_ms, debug_shutdown_timeout_ms tune deadlines. JUnit remains the existing standalone console runner; Java Debug/Test bundle ownership remains with JDTLS.

Verification (local, not CI)

  • Native bash scripts/test: 225 cases, 33 groups, 0 failures; includes actual JVM spawn/JDWP/exit/kill integration, compile failure/deadline cases, abandoned startup/cancellation/concurrent process ownership, and real filesystem report-isolation/staleness regressions.
  • bash tests/e2e/run-all.sh maven-simple: 2/2 files passed, snapshots matched (native harness uses its supplied LSP mocks; not claimed as real JDTLS evidence).
  • stylua --check .: passed.
  • luacheck lua/neotest-java: 0 warnings, 0 errors (41 files).
  • lua-language-server --check . --checklevel=Warning: no problems.
  • git diff --check: passed.
  • Real Mason JDTLS + Java Debug/Test, Gradle 9.8.2 two-module fixture, JDK 21/25, Neovim 0.13: Jupiter and Vintage Run/Debug passing/failing results matched authoritative JUnit XML; parameterized/nested Jupiter aggregation verified in both modes. Real Java Debug attach hit qa.LifecycleTest#passing() at source line 9, stepped to 10, and hit qa.LegacyTest#vintagePass() at 6, stepped to 7. Cancellation while paused and failed attach both settled as failed infrastructure, reaped only their owned JVM, and removed owned reports.

The real JDTLS gate also correctly rejected buildWorkspace status 2 with an actionable module error rather than running old classes. A forced-full build on a reopened Buildship workspace reported a prerequisite-project build-order error; the normal/default incremental workflow passed. This is recorded rather than hidden by swallowing compilation failure.

Windows runtime was unavailable on this macOS host; no live Windows claim. Upstream architecture prose still describes the old event-only/fire-and-forget flow and can be refreshed separately. No GitHub Actions were inspected or used.

Copy link
Copy Markdown
Author

Withdrawing this upstream-targeted PR at my request. The same verified implementation has already been merged into my independently maintained fork in Ajaymamtora/neotest-java#1 (merge commit e9e1054c337e). I'm keeping the changes in the fork rather than proposing them to upstream. Closing this PR without merging it into rcasia/neotest-java; upstream issue #342 remains separate.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Propagate compilation failures and bound debug test JVM termination/report waits

1 participant