Skip to content

Remove erroneous double-quoting of -javaagent arg on Windows#1832

Merged
chagong merged 2 commits intomainfrom
copilot/fix-coverage-test-issue
Feb 6, 2026
Merged

Remove erroneous double-quoting of -javaagent arg on Windows#1832
chagong merged 2 commits intomainfrom
copilot/fix-coverage-test-issue

Conversation

Copy link
Contributor

Copilot AI commented Feb 6, 2026

On Windows, the -javaagent argument for JaCoCo coverage was wrapped in double quotes before being pushed to the vmArgs array. Since vmArgs is already a string[], the debug adapter handles argument separation—the extra quotes cause Java to parse the entire string as a class name, failing with Could not find or load main class \-javaagent:....

-        if (os.platform() === 'win32') {
-            agentArg = `"${agentArg}"`;
-        }
         (debugConfiguration.vmArgs as string[]).push(agentArg);
  • Removed the Windows-specific quoting block in src/utils/launchUtils.ts
  • Removed the now-unused os import
Original prompt

This section details on the original issue you should resolve

<issue_title>"Run Test with coverage" doesn't work: "Could not find or load main class"</issue_title>
<issue_description>Coverage testing isn't working for me. When I run with coverage, the progress monitor spins indefinitely and no coverage information is provided. The test results are displayed correctly if I run without coverage.

I'm seeing the following error in the extension host logs:

Error: Could not find or load main class \-javaagent:c:\\\\Users\\\\myusername\\\\.vscode\\\\extensions\\\\vscjava.vscode-java-test-0.41.1\\\\server\\\\jacocoagent.jar=destfile=c:\\\\Users\\\\myusername\\\\AppData\\\\Roaming\\\\Code\\\\User\\\\workspaceStorage\\\\df684810f26c0547aff1b945ce0cc0fc\\\\vscjava.vscode-java-test\\\\my-project\\\\coverage\\\\jacoco.exec\\ Caused by: java.lang.ClassNotFoundException: \-javaagent:c:\\\\Users\\\\myusername\\\\.vscode\\\\extensions\\\\vscjava.vscode-java-test-0.41.1\\\\server\\\\jacocoagent.jar=destfile=c:\\\\Users\\\\myusername\\\\AppData\\\\Roaming\\\\Code\\\\User\\\\workspaceStorage\\\\df684810f26c0547aff1b945ce0cc0fc\\\\vscjava.vscode-java-test\\\\my-project\\\\coverage\\\\jacoco.exec\\

vscode-java-test Extension version: 0.41.1
VS Code Version:
Version: 1.91.1
Commit: f1e16e1e6214d7c44d078b1f0607b2388f29d729
Electron: 29.4.0
ElectronBuildId: 9728852
Chromium: 122.0.6261.156
Node.js: 20.9.0
V8: 12.2.281.27-electron.0
OS: Windows_NT x64 10.0.19045</issue_description>

<agent_instructions>Check the worked the solution mentioned in the issue, analyze the root cause and why the solution works. If it's adoptable apply the fix:
thanks @YuyaYokoyama8864 .

download .vsix file
unzip it
open extension/dist/extension.bundle.js
replace "win32"===o.platform()&&(e="${e}")
to "win32"===o.platform()&&(e=${e}) (remove double quotation)
zip and change extension to .vsix
install edited vsix
it works for methanks @YuyaYokoyama8864 .

download .vsix file
unzip it
open extension/dist/extension.bundle.js
replace "win32"===o.platform()&&(e="${e}")
to "win32"===o.platform()&&(e=${e}) (remove double quotation)
zip and change extension to .vsix
install edited vsix
it works for me</agent_instructions>

Comments on the Issue (you are @copilot in this section)

@jdneo Is there any error log in the server log? (Trigger `Java: Open Java Language Server Log File`)

Is it possible to share a sample project to us?</comment_new>
<comment_new>@jdneo
@LeonardoBevilacqua Is this still a problem in 0.42.0?</comment_new>
<comment_new>@jdneo
What's the jacoco version used in your project?</comment_new>
<comment_new>@jdneo
I'm guessing that this might be caused by the version of jacoco agent of the project is different from the embedded one in extension.

In #1723, I changed to implementation that using the one from project if it's available.

Would you mind trying the pre-release 0.42.2024080609 and let me know if the issue is fixed or not?</comment_new>
<comment_new>@jdneo
@LoveraSantiago Would you mind sharing the project that having this issue?</comment_new>


💡 You can make Copilot smarter by setting up custom instructions, customizing its development environment and configuring Model Context Protocol (MCP) servers. Learn more Copilot coding agent tips in the docs.

… Windows

On Windows, the -javaagent argument for JaCoCo coverage was wrapped in
double quotes before being pushed to the vmArgs array. Since vmArgs is
an array of strings where each element is already a separate argument,
the extra quotes caused Java to interpret the entire string as a class
name, resulting in "Could not find or load main class" errors.

Removes the Windows-specific quoting block and the now-unused os import.

Co-authored-by: chagong <831821+chagong@users.noreply.github.com>
Copilot AI changed the title [WIP] Fix coverage testing not working due to class loading error Remove erroneous double-quoting of -javaagent arg on Windows Feb 6, 2026
Copilot AI requested a review from chagong February 6, 2026 02:06
@chagong chagong marked this pull request as ready for review February 6, 2026 02:57
@chagong chagong merged commit 271603c into main Feb 6, 2026
4 checks passed
@chagong chagong deleted the copilot/fix-coverage-test-issue branch February 6, 2026 07:39
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

"Run Test with coverage" doesn't work: "Could not find or load main class"

3 participants