Support Java 9
Java Language Support extension version 0.0.41 Visual Studio Code version 1.12.1 OS: ubuntu 12.04 LTS i386 [32-bit]
With JDK 9 early access release installed on my linux box, the extension fails to load with the "Java language support requires Java 8 (using /my/path/to/java-9/bin/java)" error.
Any plans to make this extension work with JDK 9?
Thanks in advance.
This project is based on the netbeans fork of tools.jar. build-tools-jar/make.sh is a script that builds it from source; going to Java 9 is simply a matter of changing the version we build.
However, last time I checked, the netbeans tools.jar Java 9 branch was not yet very stable, so I haven't done this yet.
now that jdk 9 is released, will there be support soon for jdk 9?
ping
The main problem here is that JDK langtools, which was previously in tools.jar, was incorporated into the main java platform in Java 9. This project uses a custom build of langtools, but now when we attempt to load the custom build, we instead get the standard version. The solution is probably some kind of classloader hackery, I just haven't managed to figure it out yet.
I spent some fiddling with this last weekend and got it to load the bundled tools.jar in Java 9 using a custom classloader, and fixed the way it figures out the system classpath. That was enough to get it to run on Java 9, but when it tries to actually read Java 9 modules (which are basically jars) it fails:
Caused by: java.lang.NullPointerException
at com.sun.tools.javac.file.Locations.getPathEntries(Locations.java:149)
at com.sun.tools.javac.file.Locations.getPathEntries(Locations.java:134)
at com.sun.tools.javac.file.Locations.access$000(Locations.java:71)
at com.sun.tools.javac.file.Locations$BootClassPathLocationHandler.computePath(Locations.java:617)
at com.sun.tools.javac.file.Locations$BootClassPathLocationHandler.lazy(Locations.java:643)
at com.sun.tools.javac.file.Locations$BootClassPathLocationHandler.getLocation(Locations.java:577)
at com.sun.tools.javac.file.Locations.getLocation(Locations.java:678)
at com.sun.tools.javac.file.JavacFileManager.getLocation(JavacFileManager.java:803)
at com.sun.tools.javac.file.JavacFileManager.list(JavacFileManager.java:617)
at javax.tools.ForwardingJavaFileManager.list(ForwardingJavaFileManager.java:76)
at org.javacs.IncrementalFileManager.list(IncrementalFileManager.java:73)
at com.sun.tools.javac.api.ClientCodeWrapper$WrappedJavaFileManager.list(ClientCodeWrapper.java:233)
... 33 more
The problem is that it's the Java 8 compiler trying to read a Java 9 module. I think the best path forward here is to:
- Modify build-tools-jar to build the equivalent of tools.jar for Java 9
- Refactor vscode-javac to target Java 9 instead of Java 8
- Use jlink to create a zero-dependency launcher for each platform, so we're not dependent on what version of java the user is running
I'm not 100% sure it's worth it to invest a ton of effort in this plugin though. Microsoft is pushing their own Java plugin hard. It works by running a headless eclipse in the background, which I think is a terrible design but it's the "official plugin" now and has had a lot of polish, so everyone tends to use it.
FWIW I'd rather use this than the headless eclipse plugin that Microsoft provides.
@dvogel There's a couple people who have gotten interested in this project as a way to provide Java support in other (non-vscode) editors, and I've been playing with a Kotlin language server and getting some good ideas that could cross back over to this plugin, so there's hope 😄
It is nice to the progress! Thank you for your work. Just a little curious. Will it support Java 10 later? The Ubuntu 18.04 LTS brings Java 10 by default so It is a little annoying when it popped "Java language support requires Java 8" error. (Hence, I re-install Java 8 and set it as default)
It now runs on Java 10
Broken again in Java 11? I only get "Couldn't start client Java Language Server".
Broken again in Java 11? I only get "Couldn't start client Java Language Server".
same here
Dang, that's frustrating. Can you try to get some log info from "Output / Java":
And if that isn't available, the VSCode js console Help / Toggle Developer Tools
[Error - 1:52:31 AM] Starting client failed
Launching server using command c:\Users\blackwind\.vscode\extensions\georgewfraser.vscode-javac-0.2.13\dist\windows\bin\launcher failed.
When I run launcher.bat manually, it appears to work as intended:
01:52:42.106 INFO org.javacs.lsp.LSP connect Reading messages from queue...
01:52:42.106 INFO org.javacs.lsp.LSP$1MessageReader run Placing incoming messages on queue...
This is still an issue...
The same in Java 12. :( Well if server can't be started with newer Java versions it means that this project 90% dead.
It works up to Java 11 right now. Now that it's packaged as a standalone executable, it's pretty easy to roll forward a version, I just haven't gotten around to Java 12 just yet.