Skip to content

fix(#464): redefine_classes re-resolves statement anchors against the new source - #485

Open
debugmcpdev wants to merge 1 commit into
mainfrom
fix/464-redefine-reanchor
Open

fix(#464): redefine_classes re-resolves statement anchors against the new source#485
debugmcpdev wants to merge 1 commit into
mainfrom
fix/464-redefine-reanchor

Conversation

@debugmcpdev

Copy link
Copy Markdown
Collaborator

Closes #464.

A hot-swap invalidates line numbers, but the replant was purely by line — a statement:-anchored breakpoint silently rebound to whatever now lives at the old line, reporting verified: true. Content identities must be honored whenever line numbers are invalidated, as restart_debugging already does.

Fix

  • After a successful redefine (redefinedCount > 0), reresolveAnchors — the restart machinery, with all its awkward parts already solved (fresh file read, nearLine proximity, Substring expectedContent silently weakens the 'cannot land on the wrong line' guarantee; docs still promise it #379 multi-candidate flagging, [FEATURE] Agent-native breakpoint addressing: expectedContent assertion, statement anchors, function breakpoints #271 stale-keeps-line) — re-resolves every statement anchor against the source on disk, and the affected files are re-sent via the existing per-file setBreakpoints sync. Ordered after vm.redefineClasses by construction (it runs on the redefine response), so the JDI replant binds moved lines against the new line table — the "not a drop-in" part the issue called out.
  • The response carries the same anchorResolution: { moved, stale } shape restart_debugging returns, plus a warning when anchors went stale or a re-send failed.
  • Bridge drive-by fixed: handleClassPreparedForFunctionBreakpoints now returns its replant count and replantBreakpointsAfterRedefine adds it in, so replantedBreakpoints stops under-reporting (visible below: it reports 2 for 1 line + … well, 2 line bps here).

Verification — the issue's literal repro, live

Breakpoint at line 19 + statement-anchored breakpoint on System.out.println("val2 = " + val2); (line 23). Launch, pause at 19. Overwrite the source with the V2 file (statement shifts to 26), javac -g, redefine_classes:

→ { redefinedCount: 1, replantedBreakpoints: 2,
    anchorResolution: { moved: [{ from: 23, to: 26, statement: "System.out.println(\"val2 = \" + val2);" }], stale: [] } }
continue_execution
→ stops at RedefineTarget.main line 26      // previously: ran to completion
evaluate val2"99"                        // the hot-swapped value
  • New unit tests: moved anchor (with post-redefine setBreakpoints ordering asserted), stale anchor + warning, nothing-redefined short-circuit.
  • JdiDapServer.java compiles clean; full unit suites 3221 passed.

🤖 Generated with Claude Code

… new source

A hot-swap invalidates line numbers, but the replant was purely by line —
a statement-anchored breakpoint silently rebound to whatever now lives at
the old line, reporting verified:true. Content identities must be honored
whenever lines are invalidated (restart_debugging already does).

- After a successful redefine, reresolveAnchors (the restart machinery:
  fresh file read, nearLine proximity, #379 multi-candidate flagging,
  #271 stale-keeps-line) re-resolves every statement anchor, and the
  affected files are re-sent via setBreakpoints — ordered after
  vm.redefineClasses by construction, so the JDI replant binds moved
  lines against the new line table.
- The response carries the same anchorResolution { moved, stale } shape
  restart_debugging returns, plus a warning when anchors went stale.
- Bridge drive-by: replantedBreakpoints now counts re-planted function
  breakpoints too (the handleClassPreparedForFunctionBreakpoints return
  value was dropped).

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
@codecov

codecov Bot commented Aug 25, 2026

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 92.30769% with 1 line in your changes missing coverage. Please review.

Files with missing lines Patch % Lines
src/session/session-manager-operations.ts 92.30% 1 Missing ⚠️

📢 Thoughts on this report? Let us know!

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.

redefine_classes re-plants by line only — statement-anchored breakpoints should re-resolve by content after a hot-swap

2 participants