-
Notifications
You must be signed in to change notification settings - Fork 703
Add Java debugger support #12076
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Add Java debugger support #12076
Conversation
🚀 Dogfood this PR with:
curl -fsSL https://raw.githubusercontent.com/dotnet/aspire/main/eng/scripts/get-aspire-cli-pr.sh | bash -s -- 12076 Or
iex "& { $(irm https://raw.githubusercontent.com/dotnet/aspire/main/eng/scripts/get-aspire-cli-pr.ps1) } 12076" |
export interface JavaLaunchConfiguration extends ExecutableLaunchConfiguration { | ||
type: "java"; | ||
main_class_path?: string; | ||
project_path?: string; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
write a comment to explain why both are included
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Pull Request Overview
Adds Java debugger support to the VS Code extension, enabling detection, configuration, and launch handling for Java services.
- Introduces Java launch configuration types and a Java-specific debugger extension.
- Adds capability detection via the Java Extension Pack and updates supported capabilities.
- Provides unit tests for Java getProjectFile behavior and updates README with Java docs.
Reviewed Changes
Copilot reviewed 6 out of 6 changed files in this pull request and generated 4 comments.
Show a summary per file
File | Description |
---|---|
extension/src/test/javaDebugger.test.ts | Adds unit tests covering Java getProjectFile logic, precedence, and error cases. |
extension/src/debugger/languages/java.ts | Implements the Java ResourceDebuggerExtension and getProjectFile resolution. |
extension/src/debugger/debuggerExtensions.ts | Registers Java debugger extension when Java capability is present. |
extension/src/dcp/types.ts | Adds JavaLaunchConfiguration type and type guard. |
extension/src/capabilities.ts | Adds Java capability detection and capability list entries. |
extension/README.md | Documents Java debugger option and links to VS Code Java debugging docs. |
} | ||
} | ||
|
||
throw new Error(invalidLaunchConfiguration(JSON.stringify(launchConfig))); |
Copilot
AI
Oct 17, 2025
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The error includes the full serialized launch configuration, which may leak sensitive values (e.g., env vars) into logs. Prefer a concise, non-sensitive message (e.g., include only the type and which required fields are missing) instead of JSON-stringifying the entire object.
Copilot uses AI. Check for mistakes.
export function isJavaInstalled() { | ||
return isExtensionInstalled("vscjava.vscode-java-pack"); | ||
} |
Copilot
AI
Oct 17, 2025
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Detecting capability via the extension pack ID may miss users who installed only the Debugger for Java extension. Consider checking for either the debugger extension or the pack: return isExtensionInstalled('vscjava.vscode-java-debug') || isExtensionInstalled('vscjava.vscode-java-pack');
Copilot uses AI. Check for mistakes.
if (isJavaInstalled()) { | ||
capabilities.push("java"); | ||
capabilities.push("vscjava.vscode-java-pack"); | ||
} |
Copilot
AI
Oct 17, 2025
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
If you adjust detection to include the Debugger for Java extension, reflect that here by pushing the actual installed extension ID (prefer the debugger extension if present). This keeps capabilities aligned with what's installed.
Copilot uses AI. Check for mistakes.
The debuggers property stores common debug configuration properties for different types of Aspire services. | ||
C#-based services have common debugging properties under `project`. Python-based services have their common properties under `python`. |
Copilot
AI
Oct 17, 2025
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please include Java here for consistency with the table above. Suggest: 'Java-based services have their common properties under java
.'
Copilot uses AI. Check for mistakes.
I'll add the new I did hit a weird issue that crashes the Java debugger on startup. It looks like something is introducing duplicate environment variables. Is it possible the Java debugger already merges the launch configuration This is the stacktrace from the Language Support for Java output window: Oct 18, 2025 2:20:25 PM com.microsoft.java.debug.core.adapter.handler.LaunchRequestHandler constructEnvironmentVariables
WARNING: There are duplicated environment variables. The values specified in launch.json will be used. Here are the duplicated entries: ALLUSERSPROFILE,ANDROID_HOME,APPDATA,APPLICATION_INSIGHTS_NO_STATSBEAT,CHROME_CRASHPAD_PIPE_NAME,CommonPropertyBagPath,CommonPropertyBagWithConfigPath,COMPUTERNAME,ComSpec,CommonProgramFiles,CommonProgramFiles(x86),CommonProgramW6432,DOTNET_ROOT,DriverData,EFC_9208_1592913036,ELECTRON_RUN_AS_NODE,FPS_BROWSER_APP_PROFILE_STRING,FPS_BROWSER_USER_PROFILE_STRING,HOMEDRIVE,HOMEPATH,JAVA_HOME,LOCALAPPDATA,LOGONSERVER,NUGET_PACKAGES,NUMBER_OF_PROCESSORS,NVM_HOME,NVM_SYMLINK,ORIGINAL_XDG_CURRENT_DESKTOP,OS,OneDrive,OneDriveConsumer,PATHEXT,POWERSHELL_DISTRIBUTION_CHANNEL,PROCESSOR_ARCHITECTURE,PROCESSOR_IDENTIFIER,PROCESSOR_LEVEL,PROCESSOR_REVISION,PSModulePath,PUBLIC,Path,ProgramData,ProgramFiles,ProgramFiles(x86),ProgramW6432,SESSIONNAME,SystemDrive,SystemRoot,TEMP,TMP,USERDOMAIN,USERDOMAIN_ROAMINGPROFILE,USERNAME,USERPROFILE,VSCODE_CRASH_REPORTER_PROCESS_TYPE,VSCODE_CWD,VSCODE_DOTNET_INSTALL_TOOL_ORIGINAL_HOME,VSCODE_ESM_ENTRYPOINT,VSCODE_HANDLES_UNCAUGHT_ERRORS,VSCODE_IPC_HOOK,VSCODE_NLS_CONFIG,VSCODE_PID,ZES_ENABLE_SYSMAN,windir.
[Error - 2:20:25 PM] Oct 18, 2025, 2:20:25 PM [error response][launch]: Failed to launch debuggee VM. Reason: VM exited with status 1
Failed to launch debuggee VM. Reason: VM exited with status 1
com.microsoft.java.debug.core.DebugException: Failed to launch debuggee VM. Reason: VM exited with status 1
at com.microsoft.java.debug.core.adapter.handler.LaunchRequestHandler.launch(LaunchRequestHandler.java:326)
at com.microsoft.java.debug.core.adapter.handler.LaunchRequestHandler.handleLaunchCommand(LaunchRequestHandler.java:193)
at com.microsoft.java.debug.core.adapter.handler.LaunchRequestHandler.handle(LaunchRequestHandler.java:95)
at com.microsoft.java.debug.core.adapter.DebugAdapter.lambda$dispatchRequest$0(DebugAdapter.java:94)
at java.base/java.util.concurrent.CompletableFuture.uniComposeStage(Unknown Source)
at java.base/java.util.concurrent.CompletableFuture.thenCompose(Unknown Source)
at com.microsoft.java.debug.core.adapter.DebugAdapter.dispatchRequest(DebugAdapter.java:93)
at com.microsoft.java.debug.core.adapter.ProtocolServer.dispatchRequest(ProtocolServer.java:132)
at com.microsoft.java.debug.core.protocol.AbstractProtocolServer.lambda$new$0(AbstractProtocolServer.java:81)
at io.reactivex.internal.observers.LambdaObserver.onNext(LambdaObserver.java:63)
at io.reactivex.internal.operators.observable.ObservableObserveOn$ObserveOnObserver.drainNormal(ObservableObserveOn.java:201)
at io.reactivex.internal.operators.observable.ObservableObserveOn$ObserveOnObserver.run(ObservableObserveOn.java:255)
at io.reactivex.internal.schedulers.ScheduledRunnable.run(ScheduledRunnable.java:66)
at io.reactivex.internal.schedulers.ScheduledRunnable.call(ScheduledRunnable.java:57)
at java.base/java.util.concurrent.FutureTask.run(Unknown Source)
at java.base/java.util.concurrent.ScheduledThreadPoolExecutor$ScheduledFutureTask.run(Unknown Source)
at java.base/java.util.concurrent.ThreadPoolExecutor.runWorker(Unknown Source)
at java.base/java.util.concurrent.ThreadPoolExecutor$Worker.run(Unknown Source)
at java.base/java.lang.Thread.run(Unknown Source) |
You should place a breakpoint right before calling viscode.debug.startDebugging to see the contents of the env property. That may be a good place to start |
Description
This PR introduces Java debugger support for the VSCode extension.
This will require a corresponding change in the Community Toolkit.
cc @adamint
Checklist
<remarks />
and<code />
elements on your triple slash comments?doc-idea
templatebreaking-change
templatediagnostic
template