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

Support for JDK 20, 21? #2898

Closed
oscarvarto opened this issue Oct 8, 2023 · 14 comments
Closed

Support for JDK 20, 21? #2898

oscarvarto opened this issue Oct 8, 2023 · 14 comments

Comments

@oscarvarto
Copy link

oscarvarto commented Oct 8, 2023

Hi! I couldn't find an issue about JDK 20, 21 support, therefore I am creating this (more of a question, than an issue). I read in the README.md of the repo:

Supports compiling projects from Java 1.5 through 19

Is there a roadmap to support recent JDK versions? Sorry if this is too soon.

Also, I want to mention that there is no description of changes in the changelog for a given tag (I didn't check all, but here is an example: https://github.com/eclipse-jdtls/eclipse.jdt.ls/releases/tag/v1.28.0)
It's hard to see what were the changes.

@snjeza
Copy link
Contributor

snjeza commented Oct 8, 2023

@oscarvarto VS Code/Java LS supports JDK 20. See https://github.com/redhat-developer/vscode-java - Supports code from Java 1.5 to Java 20
JDK 21 will be supported soon - See Provide support for Java 21

@rgrunber
Copy link
Contributor

rgrunber commented Nov 1, 2023

Closing as this will be fixed in the next release with #2863 . There may be some preview features not completely implemented but those should make it in eventually.

@rgrunber rgrunber closed this as completed Nov 1, 2023
@nithin-mk
Copy link

@rgrunber The Wiki still says it supports only upto JavaSE-19 in enum executionEnvironment. I can confirm that JDK 21 is still not working with NeoVim even after updating Eclipse JDTLS to latest version 1.35.0.

@rgrunber
Copy link
Contributor

I've updated the wiki. Java 21 support has been present since https://github.com/eclipse-jdtls/eclipse.jdt.ls/blob/master/CHANGELOG.md#1300-november-30th-2023 although some of the preview features were lacking. With Java 22 out, one needs to use that in order to use those.

Do you have a JDK 21 on your system ? Is the projec you're using a Maven, Gradle or just some folder with Java source files ? Are you setting java.configuration.runtimes to contain a JDK 21 ?

@nithin-mk
Copy link

nithin-mk commented May 15, 2024

@rgrunber Thanks for updating the Wiki! Yes, I have Temurin 21 JDK installed. My project uses Maven 3.9.6. My pom.xml contains maven.compiler.source and maven.compiler.target properties set to 21. I have set ~/.config/lvim/ftplugin/java.lua as:

  settings = {
    java = {
      eclipse = {
        downloadSources = true,
      },
      configuration = {
        updateBuildConfiguration = "interactive",
        runtimes = {
          {
            name = "JavaSE-17",
            path = "~/.sdkman/candidates/java/17.0.11-tem"
          },
          {
            name = "JavaSE-21",
            path = "~/.sdkman/candidates/java/21.0.3-tem",
          },
        },
      },

according to the instructions here.

Please note that Java 17 is working perfectly with JDTLS and NeoVim when I change the maven compiler properties to 17 instead of 21. Only Java 21 is not working.

@fbricon
Copy link
Contributor

fbricon commented May 15, 2024

can you try setting absolute path to the JDKs?

@nithin-mk
Copy link

@fbricon I changed the path to absolute "/home/fci1614/.sdkman/candidates/java/21.0.3-tem".
But still I get the same errors like "Integer cannot be resolved", etc.

@nithin-mk
Copy link

@rgrunber , @fbricon I see these errors in my ~/.local/state/lvim/lsp.log.

[START][2024-05-15 23:54:10] LSP logging initiated
[ERROR][2024-05-15 23:54:10] .../vim/lsp/rpc.lua:734    "rpc"   "java"  "stderr"        "WARNING: Using incubator modules: jdk.incubator.vector\n"
[ERROR][2024-05-15 23:54:11] ...lsp/handlers.lua:535    "May 15, 2024, 11:54:11 PM Failed to load extension bundles \nLoad bundle list\norg.eclipse.core.runtime.CoreException: Load bundle list\n\tat org.eclipse.jdt.ls.core.internal.handlers.BundleUtils.loadBundles(BundleUtils.java:169)\n\tat org.eclipse.jdt.ls.core.internal.handlers.InitHandler.handleInitializationOptions(InitHandler.java:91)\n\tat org.eclipse.jdt.ls.core.internal.handlers.BaseInitHandler.initialize(BaseInitHandler.java:63)\n\tat org.eclipse.jdt.ls.core.internal.handlers.JDTLanguageServer.initialize(JDTLanguageServer.java:250)\n\tat java.base/jdk.internal.reflect.DirectMethodHandleAccessor.invoke(DirectMethodHandleAccessor.java:103)\n\tat java.base/java.lang.reflect.Method.invoke(Method.java:580)\n\tat org.eclipse.lsp4j.jsonrpc.services.GenericEndpoint.lambda$null$0(GenericEndpoint.java:65)\n\tat org.eclipse.lsp4j.jsonrpc.services.GenericEndpoint.request(GenericEndpoint.java:120)\n\tat org.eclipse.lsp4j.jsonrpc.RemoteEndpoint.handleRequest(RemoteEndpoint.java:261)\n\tat org.eclipse.lsp4j.jsonrpc.RemoteEndpoint.consume(RemoteEndpoint.java:190)\n\tat org.eclipse.jdt.ls.core.internal.ParentProcessWatcher.lambda$0(ParentProcessWatcher.java:131)\n\tat org.eclipse.lsp4j.jsonrpc.json.StreamMessageProducer.handleMessage(StreamMessageProducer.java:194)\n\tat org.eclipse.lsp4j.jsonrpc.json.StreamMessageProducer.listen(StreamMessageProducer.java:94)\n\tat org.eclipse.lsp4j.jsonrpc.json.ConcurrentMessageProcessor.run(ConcurrentMessageProcessor.java:113)\n\tat java.base/java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:572)\n\tat java.base/java.util.concurrent.FutureTask.run(FutureTask.java:317)\n\tat java.base/java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1144)\n\tat java.base/java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:642)\n\tat java.base/java.lang.Thread.run(Thread.java:1583)\nContains: Failed to get bundleInfo for bundle from /home/fci1614/.local/share/lvim/mason/packages/java-test/extension/server/com.microsoft.java.test.runner-jar-with-dependencies.jar\n"
[WARN][2024-05-15 23:54:13] .../lua/vim/lsp.lua:1072    "server_request: no handler found for"  "workspace/inlayHint/refresh"
[WARN][2024-05-15 23:54:13] .../lua/vim/lsp.lua:1072    "server_request: no handler found for"  "workspace/inlayHint/refresh"
[ERROR][2024-05-15 23:54:13] ...lsp/handlers.lua:535    "May 15, 2024, 11:54:13 PM Runtime at '/home/fci1614/.sdkman/candidates/java/21.0.3-tem' is not compatible with the 'JavaSE-21' environment"
[ERROR][2024-05-15 23:54:17] ...lsp/handlers.lua:535    "May 15, 2024, 11:54:13 PM Error occured while building workspace. Details: \n message: Unbound classpath container: 'JRE System Library [JavaSE-19]' in project 'problems'; code: 963; resource: /home/fci1614/IdeaProjects/leetcode;\n message: The project cannot be built until build path errors are resolved; code: 0; resource: /home/fci1614/IdeaProjects/leetcode;"
[WARN][2024-05-15 23:54:17] ...lsp/handlers.lua:137     "The language server jdtls triggers a registerCapability handler despite dynamicRegistration set to false. Report upstream, this warning is harmless"
[ERROR][2024-05-15 23:54:17] ...lsp/handlers.lua:535    "May 15, 2024, 11:54:17 PM class com.google.gson.internal.LinkedTreeMap cannot be cast to class java.util.ArrayList (com.google.gson.internal.LinkedTreeMap is in unnamed module of loader org.eclipse.osgi.internal.loader.EquinoxClassLoader @78d6692f; java.util.ArrayList is in module java.base of loader 'bootstrap')\nclass com.google.gson.internal.LinkedTreeMap cannot be cast to class java.util.ArrayList (com.google.gson.internal.LinkedTreeMap is in unnamed module of loader org.eclipse.osgi.internal.loader.EquinoxClassLoader @78d6692f; java.util.ArrayList is in module java.base of loader 'bootstrap')\njava.lang.ClassCastException: class com.google.gson.internal.LinkedTreeMap cannot be cast to class java.util.ArrayList (com.google.gson.internal.LinkedTreeMap is in unnamed module of loader org.eclipse.osgi.internal.loader.EquinoxClassLoader @78d6692f; java.util.ArrayList is in module java.base of loader 'bootstrap')\n\tat org.eclipse.jdt.ls.core.internal.handlers.JDTLanguageServer.synchronizeBundles(JDTLanguageServer.java:390)\n\tat org.eclipse.jdt.ls.core.internal.handlers.JDTLanguageServer$2.run(JDTLanguageServer.java:288)\n\tat org.eclipse.core.internal.jobs.Worker.run(Worker.java:63)\n"

@rgrunber
Copy link
Contributor

rgrunber commented May 15, 2024

class com.google.gson.internal.LinkedTreeMap cannot be cast to class java.util.ArrayList (com.google.gson.internal.LinkedTreeMap is in unnamed module of loader org.eclipse.osgi.internal.loader.EquinoxClassLoader @78d6692f; java.util.ArrayList is in module java.base of loader bootstrap)
class com.google.gson.internal.LinkedTreeMap cannot be cast to class java.util.ArrayList (com.google.gson.internal.LinkedTreeMap is in unnamed module of loader org.eclipse.osgi.internal.loader.EquinoxClassLoader @78d6692f; java.util.ArrayList is in module java.base of loader bootstrap)
java.lang.ClassCastException: class com.google.gson.internal.LinkedTreeMap cannot be cast to class java.util.ArrayList (com.google.gson.internal.LinkedTreeMap is in unnamed module of loader org.eclipse.osgi.internal.loader.EquinoxClassLoader @78d6692f; java.util.ArrayList is in module java.base of loader bootstrap)
    at org.eclipse.jdt.ls.core.internal.handlers.JDTLanguageServer.synchronizeBundles(JDTLanguageServer.java:390)
    at org.eclipse.jdt.ls.core.internal.handlers.JDTLanguageServer$2.run(JDTLanguageServer.java:288)
    at org.eclipse.core.internal.jobs.Worker.run(Worker.java:63)

Can you confirm what version of language server you're using ? The stacktrace offsets of your logs seem to match a much older version of JDT-LS.

These are lines 288 and 390 of JDTLanguageServer for 1.35.0 according to the stacktrace


This is what they are in 1.17.0 :


List<String> bundlesToRefresh = (ArrayList<String>) JavaLanguageServerPlugin.getInstance()

which corresponds a lot more to the casting exception.

The only other thing that stands out is Runtime at '/home/fci1614/.sdkman/candidates/java/21.0.3-tem' is not compatible with the 'JavaSE-21' environment" which could easily be due to lack of support for JavaSE-21 in 1.17.0 (October 2022).

@nithin-mk
Copy link

nithin-mk commented May 15, 2024

@rgrunber My installed JDTLS version is 1.35.0. PFA screenshot.
Screenshot 2024-05-16 021506

@rgrunber
Copy link
Contributor

Would you be able to open up a java project in NeoVim and in another terminal, run jps -lv and report back any entries that contain a reference to 'eclipse' or 'equinox' ?

@nithin-mk
Copy link

~  jps -lv
3173 /home/fci1614/.local/share/nvim/mason/packages/jdtls/plugins/org.eclipse.equinox.launcher_1.6.400.v20210924-0641.jar -Declipse.application=org.eclipse.jdt.ls.core.id1 -Dosgi.bundles.defaultStartLevel=4 -Declipse.product=org.eclipse.jdt.ls.core.product -Dlog.protocol=true -Dlog.level=ALL -Xms1g --add-modules=ALL-SYSTEM --add-opens=java.base/java.util=ALL-UNNAMED --add-opens=java.base/java.lang=ALL-UNNAMED -javaagent:/home/fci1614/.local/share/nvim/mason/packages/jdtls/lombok.jar
7525 jdk.jcmd/sun.tools.jps.Jps -Dapplication.home=/home/fci1614/.sdkman/candidates/java/21.0.3-tem -Xms8m -Djdk.module.main=jdk.jcmd
7015 /home/fci1614/.local/share/nvim/mason/packages/jdtls/plugins/org.eclipse.equinox.launcher_1.6.400.v20210924-0641.jar -Declipse.application=org.eclipse.jdt.ls.core.id1 -Dosgi.bundles.defaultStartLevel=4 -Declipse.product=org.eclipse.jdt.ls.core.product -Dlog.protocol=true -Dlog.level=ALL -Xms1g --add-modules=ALL-SYSTEM --add-opens=java.base/java.util=ALL-UNNAMED --add-opens=java.base/java.lang=ALL-UNNAMED -javaagent:/home/fci1614/.local/share/nvim/mason/packages/jdtls/lombok.jar

@rgrunber
Copy link
Contributor

rgrunber commented May 16, 2024

org.eclipse.equinox.launcher_1.6.400.v20210924-0641.jar comes from JDT-LS 1.17.0 (the main giveaway that it isn't from 1.35.0, is the qualifier, 2021-09-25). You can check for yourself at https://download.eclipse.org/jdtls/milestones/1.17.0/jdt-language-server-1.17.0-202210271413.tar.gz

$ curl -Ls https://download.eclipse.org/jdtls/milestones/1.17.0/jdt-language-server-1.17.0-202210271413.tar.gz --output - | tar -tzf - | grep org.eclipse.equinox.launcher_
plugins/org.eclipse.equinox.launcher_1.6.400.v20210924-0641.jar

$ curl -Ls https://download.eclipse.org/jdtls/milestones/1.35.0/jdt-language-server-1.35.0-202404251256.tar.gz --output - | tar -tzf - | grep org.eclipse.equinox.launcher_
plugins/org.eclipse.equinox.launcher_1.6.800.v20240330-1250.jar

Would there be a way to clear out /home/fci1614/.local/share/nvim/mason/packages/jdtls. Are there instructions at https://github.com/williamboman/mason.nvim to ensure that the latest installed version of JDT-LS is the one that's used ?

@nithin-mk
Copy link

@rgrunber It seems that Mason wasn't able to update jdtls to the latest version correctly, because the version of Mason installed as part of my distro LunarVim itself was very old. Since LunarVim is not maintained anymore, I had to change to a new distro AstroNvim to get the latest version of Mason, which in turn was able to install the latest version of jdtls. Thank you very much for the quick replies to help me fix my issue!

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

No branches or pull requests

5 participants