java-language-server icon indicating copy to clipboard operation
java-language-server copied to clipboard

Support Java 9

Open limey-git opened this issue 9 years ago • 16 comments

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.

limey-git avatar May 09 '17 20:05 limey-git

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.

georgewfraser avatar Jul 15 '17 20:07 georgewfraser

now that jdk 9 is released, will there be support soon for jdk 9?

saad749 avatar Sep 27 '17 19:09 saad749

ping

J-Liu avatar Nov 07 '17 02:11 J-Liu

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.

georgewfraser avatar Nov 09 '17 07:11 georgewfraser

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.

georgewfraser avatar Nov 18 '17 20:11 georgewfraser

FWIW I'd rather use this than the headless eclipse plugin that Microsoft provides.

dvogel avatar Apr 14 '18 04:04 dvogel

@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 😄

georgewfraser avatar Apr 15 '18 02:04 georgewfraser

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)

adamxchen avatar Apr 27 '18 23:04 adamxchen

It now runs on Java 10

georgewfraser avatar Sep 16 '18 18:09 georgewfraser

Broken again in Java 11? I only get "Couldn't start client Java Language Server".

blackwind avatar Feb 03 '19 11:02 blackwind

Broken again in Java 11? I only get "Couldn't start client Java Language Server".

same here

ivanzorcic avatar Feb 04 '19 10:02 ivanzorcic

Dang, that's frustrating. Can you try to get some log info from "Output / Java":

screen shot 2019-02-09 at 11 25 00 am

And if that isn't available, the VSCode js console Help / Toggle Developer Tools

georgewfraser avatar Feb 09 '19 17:02 georgewfraser

[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...

blackwind avatar Feb 10 '19 08:02 blackwind

This is still an issue...

drujd avatar Apr 03 '19 23:04 drujd

The same in Java 12. :( Well if server can't be started with newer Java versions it means that this project 90% dead.

mkpaz avatar Jul 12 '19 15:07 mkpaz

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.

georgewfraser avatar Jul 17 '19 15:07 georgewfraser