feat(java): add redefine_classes MCP tool for JVM hot-reload#26
Merged
debugmcpdev merged 4 commits intodebugmcp:mainfrom Mar 28, 2026
Merged
feat(java): add redefine_classes MCP tool for JVM hot-reload#26debugmcpdev merged 4 commits intodebugmcp:mainfrom
debugmcpdev merged 4 commits intodebugmcp:mainfrom
Conversation
Adds a new redefine_classes tool that hot-swaps changed Java classes into a running JVM using JDI VirtualMachine.redefineClasses(). The tool scans a classes directory for .class files modified after a given timestamp, matches them against loaded classes, and redefines them. Returns redefined/skipped/failed counts and the newest file timestamp for incremental follow-up calls. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
75dc254 to
1398af4
Compare
Codecov Report❌ Patch coverage is
📢 Thoughts on this report? Let us know! |
…e_debug_session The create_debug_session attach shortcut did not forward stopOnEntry, and the missing value caused attachToProcess to default to PAUSED state even though the VM was not actually suspended. Now stopOnEntry is forwarded and defaults to false for the attach shortcut, so attaching reports RUNNING state by default. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
b21b183 to
74ee972
Compare
handleAttach did not call vm.suspend(), so stopOnEntry only affected the MCP session state but not the actual JVM. Now the VM is suspended after attach when stopOnEntry=true, and resumed on continue. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Tests cover: - redefine_classes tool registration and input schema - redefine_classes dispatch with correct args and sinceTimestamp default - redefine_classes error propagation - create_debug_session attach defaults stopOnEntry to false - create_debug_session attach forwards stopOnEntry=true - attach_to_process defaults stopOnEntry to false - attach_to_process forwards stopOnEntry=true Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Collaborator
|
Thanks @Finomosec — this is a great feature! Hot-swapping classes into a running JVM opens up some really interesting possibilities for interactive debugging workflows. Merged, and we've done a small follow-up cleanup:
Appreciate the contribution! |
debugmcpdev
pushed a commit
that referenced
this pull request
Mar 28, 2026
Follow-up to PR #26 (feat/java-hot-reload): - Remove unused waitForInitialBreakpointPause private method (never called) - Add unit tests for SessionManager.redefineClasses() covering success, failures, missing proxy, empty response body, and default args Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
debugmcpdev
pushed a commit
that referenced
this pull request
Mar 28, 2026
PR #26 changed attach_to_process and create_debug_session (attach path) to default stopOnEntry to false, but this broke attach to JVMs started with suspend=y — the session reported RUNNING instead of PAUSED. Revert to passing stopOnEntry as-is (undefined when not specified), which lets the session manager preserve the original behavior: attach defaults to PAUSED state, matching the common suspend=y workflow. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
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
redefine_classesMCP tool that hot-swaps changed Java classes into a running JVM using JDIVirtualMachine.redefineClasses().classfiles modified after a given timestamp, matches them against loaded classes, and redefines themstopOnEntrynot being forwarded increate_debug_sessionandattach_to_process, defaulting tofalsefor attach mode so sessions report RUNNING instead of falsely reporting PAUSEDChanges
JdiDapServer.java: NewhandleRedefineClassesDAP command with directory scanning, FQCN matching, and per-class error handlingsession-manager-operations.ts: NewredefineClasses()method +RedefineClassesResultinterfaceserver.ts: Tool definition + dispatch forredefine_classes; forwardstopOnEntrywith?? falsedefault in both attach code pathsTest plan