Repository navigation
Description
What happened?
For Java, the gutter only offers run actions (Run Foo, Test class Foo, Foo.bar). There is no Debug: ... entry, unlike Rust/Go/Python/JS/TS where the gutter arrow shows both a run action and Debug: ... (see zed-industries/zed#60034 for a Go/Delve example).
Cause, from Zed's source:
crates/editor/src/code_actions.rs::debug_scenariosbuildsDebugScenarios by callingDapStore::debug_scenario_for_build_taskfor each resolved task.crates/project/src/debugger/dap_store.rswalksDapRegistry::global(cx).locators()and yieldsNonewhen no locator accepts the task.crates/project/src/debugger/locators.rsonly shipscargo,go,node,python.- This extension declares
[debug_adapters.Java]but no[debug_locators.*], andsrc/java.rsonly implementsget_dap_binary/dap_request_kind.
So java-main, java-test-method, java-test-method-nested, java-test-class and java-test-class-nested tasks never get a debug counterpart, and the gutter shows run only.
What did you expect to happen?
Clicking the gutter arrow next to a @Test method, a test class, or a main method should offer both the existing run action and Debug: <label>, like IntelliJ.
Right now the only way to debug is a hand-written .zed/debug.json plus F4, and those scenarios never show up in the gutter.
Scope
Tests are the important half here, so a locator should cover:
java-mainjava-test-method/java-test-method-nestedjava-test-class/java-test-class-nested
(java-test-all — "Run tests" for a whole file/module — I'd leave out of a first PR.)
Suggested implementation
Declare [debug_locators.java] and implement dap_locator_create_scenario. No build phase is needed: the launch config is fully derivable from the task template, so the returned DebugScenario can omit build. dap_request_kind already maps request: "launch" correctly, so it needs no change.
Note that the table name must be snake_case ([debug_locators.java]); a kebab-case [debug-locators.java] silently fails to register — see zed-industries/zed#33040.
Classpath and main-class resolution already exist in src/debugger.rs::inject_config: it turns classPaths: ["$Test"] into a vscode.java.resolveClasspath call with test scope, and resolves the main class via vscode.java.resolveMainClass. So the plumbing for test scope is already there.
For main methods:
{ "request": "launch", "mainClass": "<package>.<Class>", "classPaths": ["$Auto"], "cwd": "$ZED_WORKTREE_ROOT" }For tests, the missing piece is an entry point. debug_adapter_schemas/Java.json only exposes mainClass + args, and JUnit has no main, so the JVM has to be started with a test runner as mainClass. Two options:
- Ship a runner jar (what VS Code does): download
com.microsoft.java.test.runner(from microsoft/vscode-java-test) the same way this extension already downloads the java-debug plugin, append it toclassPaths, and usecom.microsoft.java.test.runner.Launcherwith-testName <Class#method> -classNames <Class>. Works for JUnit 4/5/TestNG without requiring the project to declare extra dependencies. - Use
junit-platform-console-standalone:mainClass: "org.junit.platform.console.ConsoleLauncher", args--select-class=<fqcn>or--select-method=<fqcn>#<method>, with the standalone jar appended toclassPaths. Simpler, but JUnit 5 only, and still needs a bundled jar.
Option 1 matches VS Code and covers @ParameterizedTest and nested classes through the existing java_outer_class_name capture (Outer$Inner). Which would you prefer? I'm happy to implement either, and to split it into "main methods first, tests next" if you'd rather review it in two PRs.
Related
- feature request: add debugger support #67 — add debugger support (adapter only, no locator)
- Add ZED_CUSTOM_JAVA_PACKAGE variable? #193 — debug scenarios have no Java package variable; also states extensions cannot do this, which is no longer true now that
dap_locator_create_scenario/run_dap_locatorexist - Surface user debug configurations in the code actions "Debug" menu zed-industries/zed#60034 — gutter does show run + debug once a locator matches
- Debugger: debug-locators don't appear to actually work in extensions zed-industries/zed#33040 —
[debug_locators.x]registration works; the docs example was wrong - https://zed.dev/docs/extensions/debugger-extensions#defining-debug-locators
Environment
- Zed: v1.27.0
- Java extension: v6.8.30
- OS: macOS 27.0.1 (aarch64)
- JDK 21, Maven project (JUnit 5)
Activity
tartarughina commentedon Nov 11, 2026
@fwrq41251 thanks for sharing the findings above. I've missed that extensions were able to provide such option.
About the implementation details:
Add Java main-method gutter debugging for JDTLS and Metals (#330)