Skip to content

Conversation

marshalhayes
Copy link

@marshalhayes marshalhayes commented Oct 16, 2025

Description

This PR introduces Java debugger support for the VSCode extension.

This will require a corresponding change in the Community Toolkit.

cc @adamint

Checklist

  • Is this feature complete?
    • Yes. Ready to ship.
    • No. Follow-up changes expected.
  • Are you including unit tests for the changes and scenario tests if relevant?
    • Yes
    • No
  • Did you add public API?
    • Yes
      • If yes, did you have an API Review for it?
        • Yes
        • No
      • Did you add <remarks /> and <code /> elements on your triple slash comments?
        • Yes
        • No
    • No
  • Does the change make any security assumptions or guarantees?
    • Yes
      • If yes, have you done a threat model and had a security review?
        • Yes
        • No
    • No
  • Does the change require an update in our Aspire docs?

Copy link
Contributor

github-actions bot commented Oct 16, 2025

🚀 Dogfood this PR with:

⚠️ WARNING: Do not do this without first carefully reviewing the code of this PR to satisfy yourself it is safe.

curl -fsSL https://raw.githubusercontent.com/dotnet/aspire/main/eng/scripts/get-aspire-cli-pr.sh | bash -s -- 12076

Or

  • Run remotely in PowerShell:
iex "& { $(irm https://raw.githubusercontent.com/dotnet/aspire/main/eng/scripts/get-aspire-cli-pr.ps1) } 12076"

@dotnet-policy-service dotnet-policy-service bot added the community-contribution Indicates that the PR has been added by a community member label Oct 16, 2025
export interface JavaLaunchConfiguration extends ExecutableLaunchConfiguration {
type: "java";
main_class_path?: string;
project_path?: string;
Copy link
Member

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

@marshalhayes marshalhayes marked this pull request as ready for review October 17, 2025 03:09
@Copilot Copilot AI review requested due to automatic review settings October 17, 2025 03:09
Copy link
Contributor

@Copilot Copilot AI left a 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)));
Copy link

Copilot AI Oct 17, 2025

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.

Comment on lines +22 to +24
export function isJavaInstalled() {
return isExtensionInstalled("vscjava.vscode-java-pack");
}
Copy link

Copilot AI Oct 17, 2025

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.

Comment on lines +44 to +47
if (isJavaInstalled()) {
capabilities.push("java");
capabilities.push("vscjava.vscode-java-pack");
}
Copy link

Copilot AI Oct 17, 2025

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.

Comment on lines 51 to 52
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`.
Copy link

Copilot AI Oct 17, 2025

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.

@marshalhayes
Copy link
Author

I'll add the new getSupportedFileTypes to the debugger extension soon.

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 env with process.env?

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:25PM [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)

@adamint
Copy link
Member

adamint commented Oct 18, 2025

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

area-extension community-contribution Indicates that the PR has been added by a community member

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants