Skip to content

fix(java): one stopped event per JDI event set - #1393

Merged
debugmcpdev merged 2 commits into
mainfrom
fix/java-one-stop-per-event-set
Nov 29, 2026
Merged

debugmcpdev merged 2 commits into
mainfrom
fix/java-one-stop-per-event-set

Conversation

@debugmcpdev

@debugmcpdev debugmcpdev commented Nov 29, 2026 •

Copy link
Copy Markdown
Collaborator

Closes #1383.

What changes

When a step lands on a line that has a breakpoint, JDI delivers the step's completion and the breakpoint hit as two events in one event set. The bridge sent a DAP stopped event for each: step, then breakpoint a millisecond later, for one suspension. Measured through the server: 49 of 300 step_over calls on a loop with one breakpoint line.

  • The bridge's event loop now collects one stop per event set and sends it after every event of the set has been handled.
  • A stopping breakpoint (line or function) takes precedence over a step, which is how debugpy and js-debug report the same step. An exception takes precedence over both.
  • allThreadsStopped, and the value continue later acts on, now come from the event set's own suspend policy. Before, a step onto a breakpoint with suspendPolicy: "thread" reported that one thread had stopped while the JVM had suspended all of them, and the next continue left every other thread suspended. With the order HotSpot delivers the two events, that was already so before this change; the review found it.
  • Conditions, the one-shot step request, class-prepare handling and the resume decision are unchanged.

Tests

tests/adapters/java/integration/java-event-set-stop.test.ts, four cases against the real bridge and a real JVM:

Case Asserts On the previous bridge
step onto a breakpoint line, then a plain step one stopped, reason breakpoint; then one stopped, reason step fails: [step, breakpoint]
step onto a breakpoint whose condition is false one stopped, reason step passes
stepIn onto a function breakpoint one stopped, reason function breakpoint fails: two stops
two threads, step onto a thread-policy breakpoint, continue allThreadsStopped: true, and the program runs to its end fails: two stops (with only this change's first commit: false, and the program never ends)

Review

A Gemini review with a mutation pass, two rounds. Round one found the allThreadsStopped defect (major) and that the first version of the test could pass without the step branch stopping at all. Round two: nothing above a note. Nine mutants in all; seven are killed. Two cannot be produced with a real JVM and survive by construction: a breakpoint event delivered before the step event in a set, and an exception event sharing a set with a step.

One pre-existing thing the reviewer noted and this change leaves alone: a pause for one named thread while every thread is already suspended records "not all threads stopped". The server does not send a pause while paused.

Verified

Rebased on main after the launch-port fix, head f70ff96e.

  • Windows: the new test 4 of 4, three times; the Java integration tests 16 of 16; the Java adapter unit tests 202; the eight Java end-to-end suites 22 of 22.
  • Linux: the new test 4 of 4, three times; the Java integration tests 16 of 16; the Java adapter unit tests 202; the eight Java end-to-end suites 22 of 22.

Who wrote what

The change and its tests were written by a GPT worker, in two commits (the second answers the review). The manager session (Claude) verified each failing-first run and wrote the changelog entry and this description.

🤖 Generated with Claude Code

https://claude.ai/code/session_015BDrn82vMcRzWFDD9aUbZs

cynarlab and others added 2 commits November 29, 2026 17:15
A step that lands on a line with a breakpoint arrives from JDI as a
StepEvent and a BreakpointEvent in one event set. The bridge sent a
DAP stopped event for each, so one suspension became two stops in the
core (measured: 49 of 300 step_over calls on a loop with one
breakpoint line).

The event loop now collects one stop per set and sends it after every
event of the set has been handled. A stopping breakpoint takes
precedence over a step, as debugpy and js-debug report that step; an
exception takes precedence over both. Conditions, the one-shot step
request, class-prepare handling and the resume decision are unchanged.

Test: an integration case steps onto a breakpoint line and asserts one
stopped event with reason breakpoint. It fails on the previous bridge
with [step, breakpoint].

The change and the test were written by a GPT worker. The manager
session verified the failing-first run and wrote the changelog entry.

Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_015BDrn82vMcRzWFDD9aUbZs
Review finding on the previous commit. A step request suspends all
threads; a line breakpoint with suspendPolicy "thread" suspends one.
When a step lands on such a breakpoint JDI suspends by the set's most
restrictive policy, so every thread is suspended, but the bridge took
allThreadsStopped from the breakpoint request alone and reported
false. The next continue then resumed that one thread and left every
other thread suspended. With the order HotSpot delivers the two events
this predates the previous commit.

The one stopped event of a set, and lastStopAllThreads, now take the
value from eventSet.suspendPolicy().

Tests: the integration file grows from one case to four. A second
plain step (the step branch must stop by itself), a false-condition
breakpoint together with a step (reason step), stepIn onto a function
breakpoint (reason function breakpoint), and a two-thread program
stepped onto a thread-policy breakpoint and continued to its end. The
last fails on the previous commit. The test also retries the bridge's
start when its reserved port is lost, keeps draining the bridge's
pipes, and ends its two children independently.

Found by a Gemini review with a mutation pass; written by the GPT
worker that wrote the previous commit; verified by the manager
session, which also extended the changelog entry.

Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_015BDrn82vMcRzWFDD9aUbZs
@codecov

codecov Bot commented Nov 29, 2026

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.

📢 Thoughts on this report? Let us know!

@debugmcpdev
debugmcpdev marked this pull request as ready for review November 29, 2026 22:47
@debugmcpdev
debugmcpdev merged commit 61019b1 into main Nov 29, 2026
18 checks passed
@debugmcpdev
debugmcpdev deleted the fix/java-one-stop-per-event-set branch November 29, 2026 22:47
debugmcpdev pushed a commit that referenced this pull request Nov 29, 2026
Brings in the two Java bridge fixes (#1387, #1393). No conflicts; no
file of this change is touched by them.

Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_015BDrn82vMcRzWFDD9aUbZs
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.

java: a step that lands on a line with a breakpoint is announced as two stops (the JDI bridge sends one stopped event per event in a JDI event set)

2 participants