Skip to content

Java Support v3.0.0

Choose a tag to compare

@github-actions github-actions released this 16 Nov 14:39
· 21 commits to main since this release
1cab000

Java 3.0.0

中文

Java Support 不再随包附带 Eclipse JDT Language Server 和运行它的 JDK,改为使用你电脑上安装的 JDT LS,做法和 Go 插件使用你自己的 gopls 一样。插件包从约 250 MB 降到几 MB,安装和更新不再需要下载语言服务器。

不兼容变更

升级后需要先在电脑上准备两样东西,否则打开 Java 文件时语言服务不会启动:

  • Eclipse JDT Language Server。插件按以下顺序查找,用第一个找到的:
    1. 设置 → 语言与框架 → Java →「语言服务器目录」(新增)。在这里选了目录,就只用这个目录,目录不对时直接报错,不会再去找别的安装;
    2. 环境变量 JDTLS_HOME;
    3. PATH 上的 jdtls 启动脚本所属的安装;
    4. 包管理器的安装位置:Homebrew(brew install jdtls)、Linuxbrew、mason.nvim、Scoop;
    5. VS Code Java 扩展(redhat.java)自带的语言服务器,取最新版本。
  • JDK 21 或更新版本,用来运行 JDT LS。它是新增的「JDK for JDT LS」工具,在设置 → 构建、执行、部署 → 工具链里显示和选择。不选时自动使用找到的最高版本 JDK。项目自己用的 JDK 仍然是原来的「JDK」工具,可以是 Java 8 等旧版本,两者互不影响。JDK 搜索位置新增 Homebrew 的 openjdk 和 openjdk@N。

找不到 JDT LS 或运行它的 JDK 低于 21 时,语言服务启动失败,错误信息会说明怎么安装或去哪里设置。

其他变化

  • 插件包只保留插件自己加给 JDT LS 的内容:Lombok、java-debug 和 vscode-java-test 的扩展包。调试、测试和 Lombok 支持不变。
  • 不再修补 JDT LS 的反编译器。2.0 的包修补了 JDT LS 1.61 遇到缺失内部类时整个外部类反编译为空的问题,现在使用你安装的 JDT LS,这个修补不再生效:缺少内部类的残缺旧库,打开反编译类可能为空。
  • 已测试的 JDT LS 版本:1.61.0(CI 固定版本)和 Homebrew 1.60.0。更旧的版本可能和随包的 java-debug、vscode-java-test 扩展不兼容。
  • JDT 只能为它支持的 Java 版本编译。没有为项目选 JDK 时,JDT 用运行它的 JDK 编译;这个 JDK 比 JDT LS 支持的最新 Java 还新(例如 JDT LS 1.61 跑在 JDK 26 上)时,编译会报错。为项目选择 JDK 即可。

兼容性

宿主要求与 2.0.1 相同,需要支持 launch.kind: "backend" 的语言服务器启动和 {kind: "tool"} 的启动答复。
插件声明了 jdtls-runtime 工具,宿主需要按 requiresTools 把它的解析结果传给启动函数,才能在 JDK 低于 21 时给出明确提示;不传时由宿主的工具解析和 JDT LS 自己报错。


English

Java Support no longer bundles the Eclipse JDT Language Server or the JDK that runs it. It uses the JDT LS installed on your computer, the same way the Go plugin uses your own gopls. The package shrinks from about 250 MB to a few MB, and installing or updating the plugin no longer downloads a language server.

Breaking changes

Before the language server can start, the computer needs:

  • Eclipse JDT Language Server. The plugin uses the first one it finds:
    1. Settings → Languages & Frameworks → Java → Language server folder (new). A folder chosen there is the only one used; a folder without JDT LS fails the start instead of falling back to another installation;
    2. the JDTLS_HOME environment variable;
    3. the installation of a jdtls launcher on PATH;
    4. package-manager locations: Homebrew (brew install jdtls), Linuxbrew, mason.nvim and Scoop;
    5. the language server inside the VS Code Java extension (redhat.java), newest version first.
  • JDK 21 or later to run JDT LS. It is the new JDK for JDT LS tool, listed and chosen under Settings → Build, Execution, Deployment → Toolchains. Without a choice the highest JDK found is used. The project's own JDK is still the JDK tool and may be an older release such as Java 8; the two are independent. JDK discovery now also covers Homebrew's openjdk and openjdk@N.

When JDT LS is missing, or the JDK for it is older than 21, the language server does not start and the error says how to install or where to choose it.

Other changes

  • The package keeps only what the plugin adds to JDT LS: Lombok and the java-debug and vscode-java-test extension bundles. Debugging, tests and Lombok work as before.
  • The JDT LS decompiler is no longer patched. The 2.0 package fixed JDT LS 1.61 decompiling an outer class to nothing when an inner class is missing; with your own JDT LS that fix no longer applies, so classes of incomplete legacy libraries may open empty.
  • Tested JDT LS versions: 1.61.0 (pinned in CI) and Homebrew 1.60.0. Older versions may not work with the packaged java-debug and vscode-java-test bundles.
  • JDT compiles only for the Java releases it supports. Without a JDK chosen for the project, JDT compiles against the JDK that runs it; when that JDK is newer than the latest Java the JDT LS supports (for example JDT LS 1.61 on JDK 26), compilation fails. Choose a JDK for the project.

Compatibility

Host requirements are unchanged from 2.0.1: a backend-resolved language server launch (launch.kind: "backend") answered with {kind: "tool"}.
The plugin declares the jdtls-runtime tool; a host that passes its resolution to the launch function, as requiresTools asks, gets a clear error for a JDK older than 21. Otherwise the host's tool resolution and JDT LS report the problem.

SHA-256

2b113fe4702073d0411e43232bae193c9bc30962e6e17b7a7dd1da1bcceaa591  Lithe-Java-Support-3.0.0-darwin-arm64.zip
3433d6e86a3368cbfc9e02d04601d291227f996817f27c6a7e4168d2c1c187ea  Lithe-Java-Support-3.0.0-darwin-x64.zip
a3d94ac5d5f1e7c433a2f74c24c988289300fc922f9a36f1ee23cf321f0b7ad2  Lithe-Java-Support-3.0.0-windows-x64.zip
14340e11c876cb5e924aacf8f6cdce56baba35c0e0b961706f219d602dba7c3c  Lithe-Java-Support-3.0.0-linux-arm64.zip
c01dc86388050d27114e8c11e23494c2b8f25d4ca30f633cd8b0909bb9cbb116  Lithe-Java-Support-3.0.0-linux-x64.zip