Repository navigation
Description
Describe the bug
When another extension contributes a bundle (a jar listed in contributes.javaExtensions) that the Java language server (JDT LS) already ships at the same version, JDT LS fails to install it and logs an error each time it starts.
Test Runner for Java (vscjava.vscode-java-test) 0.47.0 contributes server/org.objectweb.asm_9.10.1.jar. The JDT LS bundled with redhat.java 1.58.0 ships the same jar in server/plugins/org.objectweb.asm_9.10.1.jar. The install fails with:
!MESSAGE Install bundle failure ~/.vscode/extensions/vscjava.vscode-java-test-0.47.0/server/org.objectweb.asm_9.10.1.jar
!STACK 0
org.osgi.framework.BundleException: A bundle is already installed with the name "org.objectweb.asm" and version "9.10.1"
at org.eclipse.osgi.container.ModuleContainer.install(ModuleContainer.java:479)
at org.eclipse.osgi.storage.Storage.install(Storage.java:753)
at org.eclipse.osgi.internal.framework.BundleContextImpl.installBundle(BundleContextImpl.java:183)
at org.eclipse.osgi.internal.framework.BundleContextImpl.installBundle(BundleContextImpl.java:176)
at org.eclipse.jdt.ls.core.internal.handlers.BundleUtils.installBundle(BundleUtils.java:191)
at org.eclipse.jdt.ls.core.internal.handlers.BundleUtils.loadBundles(BundleUtils.java:161)
BundleUtils.loadBundles records the failure and goes on with the other bundles, so the remaining contributed bundles still install and start. The visible effect I saw is the error in the server log.
The extension can't avoid this on its own. If it stops shipping org.objectweb.asm, its other bundles (org.objectweb.asm.commons, org.objectweb.asm.tree, org.jacoco.core and its own plugin require org.objectweb.asm in [9.10.1,9.11)) only resolve while JDT LS ships a matching version. JDT LS doesn't pin that version: org.eclipse.jdt.ls.tp.target lists <unit id="org.objectweb.asm" version="0.0.0" />.
To Reproduce
Steps to reproduce the behavior:
- Install redhat.java 1.58.0 and Test Runner for Java (
vscjava.vscode-java-test) 0.47.0 from the Marketplace. - Open any Maven or Gradle Java project and wait for the language server to start.
- Run Java: Open Java Language Server Log File and search for
already installed.
Expected behavior
A contributed jar that is the same bundle and version the server already ships is skipped, with no error.
Screenshots
No response
Environment
- Operating System: macOS (Apple silicon, darwin-arm64)
- JDK version: the JRE bundled with redhat.java (25.0.4.1)
- Visual Studio Code version: 1.148.0
- Java extension version: 1.58.0 (JDT LS 1.63.0.202610161533)
Additional Information
A possible fix in vscode-java: collectJavaExtensions in src/plugin.ts leaves out a contributed jar when the server's plugins folder already has a jar with the same file name. p2 names jars <symbolicName>_<version>.jar, so the same file name means the same bundle at the same version. A different version is still passed on, so an extension that needs another version keeps working.
I tried this in a local build (1.59.0 with JDT LS built from source). The bundle list skipped org.objectweb.asm_9.10.1.jar from Test Runner for Java, and the "already installed" error was gone from the server log. I can open a pull request if this approach is acceptable.
Activity