From bc00302ef8c43cffb3e9cf451008c00c7e4cc54a Mon Sep 17 00:00:00 2001 From: langxp Date: Thu, 12 Nov 2026 19:03:38 +0800 Subject: [PATCH] fix(debugger): echo the Java launch command in the debug console (#2930) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Java Debug launches through java-debug in jdtls, which bypasses the Run process that echoes its command line. Debug now prints the equivalent java … -cp … Main … command after the build and classpath resolution, so Debug and Run output stay comparable. Co-authored-by: kradme <17811095+kradme@users.noreply.github.com> --- src/features/debugger/__tests__/java.test.ts | 12 ++++++++++++ src/features/debugger/java.ts | 3 +++ 2 files changed, 15 insertions(+) diff --git a/src/features/debugger/__tests__/java.test.ts b/src/features/debugger/__tests__/java.test.ts index dfa91e832..d01dfdc8b 100644 --- a/src/features/debugger/__tests__/java.test.ts +++ b/src/features/debugger/__tests__/java.test.ts @@ -95,6 +95,18 @@ describe("Java debugging (java-debug through jdtls)", () => { }); }); + it("echoes the equivalent Java command in the Debug console", async () => { + const report = vi.fn(); + await javaLaunchConfig(app, "/p", { + request: 1, + signal: new AbortController().signal, + report, + }); + expect(report).toHaveBeenCalledWith( + '/jdk21/bin/java -Xmx1g -cp /p/target/classes:/m2/a.jar a.Main --port "8081 x"\n', + ); + }); + it("debugs Spring Boot with coloured console output, as Run does", async () => { const boot = { ...app, kind: "spring-boot" }; expect(JSON.parse((await javaLaunchConfig(boot, "/p")).extraJson!).vmArgs).toBe( diff --git a/src/features/debugger/java.ts b/src/features/debugger/java.ts index 8cf2bc75a..d7ff77fd7 100644 --- a/src/features/debugger/java.ts +++ b/src/features/debugger/java.ts @@ -139,6 +139,9 @@ export async function javaLaunchConfig( const classPaths = parsed.explicitClasspath ? parsed.explicitClasspath.split(info.pathListSeparator) : info.classPaths; + // java-debug starts the JVM itself, bypassing the Run process that echoes its + // command line. Echo the equivalent launch here so Debug and Run stay comparable. + preparation?.report?.(`${joinJavaArgs([resolved.command, ...resolved.args])}\n`); if (kotlin) { return { name: rc.name,