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,