Skip to content
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

Language Server fails to start with multiple --add-exports in java.jdt.ls.vmargs #3577

Closed
paulmedynski-microsoft opened this issue Apr 16, 2024 · 4 comments · Fixed by #3578
Labels

Comments

@paulmedynski-microsoft
Copy link

The Language Server fails to start when multiple ---add-exports are specified in the java.jdt.ls.vmargs setting.

For example these VSCode settings (in .vscode/settings.json) start the Language Server correctly:

{
  "java.jdt.ls.vmargs": "--add-exports java.xml/com.sun.org.apache.xerces.internal.impl.dtd=ALL-UNNAMED",
  "java.trace.server": "verbose"
}

These settings do not:

{
  "java.jdt.ls.vmargs": "--add-exports java.xml/com.sun.org.apache.xerces.internal.impl.dtd=ALL-UNNAMED --add-exports java.xml/com.sun.org.apache.xerces.internal.xni.parser=ALL-UNNAMED --add-exports java.xml/com.sun.org.apache.xerces.internal.xni.grammars=ALL-UNNAMED --add-exports java.xml/com.sun.org.apache.xerces.internal.util=ALL-UNNAMED --add-exports java.xml/com.sun.org.apache.xerces.internal.parsers=ALL-UNNAMED --add-exports java.xml/com.sun.org.apache.xerces.internal.jaxp=ALL-UNNAMED"
  "java.trace.server": "verbose"
}

I see this error in the Language Support for Java output pane:

Error: Could not find or load main class java.xml.com.sun.org.apache.xerces.internal.xni.parser=ALL-UNNAMED
Caused by: java.lang.ClassNotFoundException: java.xml.com.sun.org.apache.xerces.internal.xni.parser=ALL-UNNAMED

I don't see any errors reported in the Chrome dev tools console, or in the Language Server workspace logs.

Environment
  • Operating System: Windows 11 and WSL2 Debian 12
  • JDK version: 21.0.1
  • Visual Studio Code version: 1.88.1
  • Java extension version: v1.30.2024041608 (pre-release)
Steps To Reproduce
  1. Add multiple --add-exports arguments to the java.jdt.ls.vmargs value in VSCode settings.json.
  2. Open a Java project workspace.
Current Result

The Language Server fails to start, and reports the above error to the Output pane.

Expected Result

The Language Server starts with all --add-exports supplied to the JVM.

@rgrunber rgrunber added the bug label Apr 16, 2024
@rgrunber
Copy link
Member

rgrunber commented Apr 16, 2024

I'm able to reproduce this as well. It's due to :

vmargs.forEach(arg => {
// remove all standalone double quotes
arg = arg.replace(/(\\)?"/g, ($0, $1) => { return ($1 ? $0 : ''); });
// unescape all escaped double quotes
arg = arg.replace(/(\\)"/g, '"');
if (params.indexOf(arg) < 0) {
params.push(arg);
}
});
. After the first --add-exports is pushed, the subsequent ones are skipped causing it to appear as if one of the arguments is being run as the main class.

@snjeza can you think of any JVM arguments that when duplicated would produce an issue starting up ? The code dates back to 2016 so maybe we should relax the restriction.

@snjeza
Copy link
Contributor

snjeza commented Apr 17, 2024

can you think of any JVM arguments that when duplicated would produce an issue starting up ? #50 so maybe we should relax the restriction.

I agree, we should relax the restriction.

@paulmedynski-microsoft
Copy link
Author

Thanks for the quick turnaround! Is there anything I can do with my local extension installation to make a similar change while I wait for the next release?

@rgrunber
Copy link
Member

Once the change is merged, the pre-release stream should contain the fix the next day so you could definitely try that. I checked if there was some workaround to bypass the incorrect behaviour in a current released version, but there doesn't seem to be any.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants