diff --git a/Cargo.lock b/Cargo.lock index 672b55a..474e357 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -397,6 +397,7 @@ dependencies = [ "libc", "lithe-java-domain", "lithe-plugin-sdk", + "regex", "serde_json", "sha2", "url", diff --git a/NOTICE b/NOTICE index f7f0b00..bb247c9 100644 --- a/NOTICE +++ b/NOTICE @@ -15,9 +15,25 @@ copied into the package next to the component: Microsoft vscode-java-test MIT License (JUnit runner and plugin) https://github.com/microsoft/vscode-java-test -The package does not include the Eclipse JDT Language Server or a Java -runtime. The plugin runs the JDT LS installation and the JDK the user installs -(https://download.eclipse.org/jdtls/, Eclipse Public License 2.0). +The plugin ZIP does not contain the Eclipse JDT Language Server or a Java +runtime. The host reuses compatible installations or downloads the following +pinned dependencies into separate managed state, preserving their upstream +license and notice files: + + Eclipse JDT Language Server 1.61.0 + Eclipse Public License 2.0; included components retain their own licenses + https://github.com/eclipse-jdtls/eclipse.jdt.ls + https://download.eclipse.org/jdtls/milestones/1.61.0/ + Microsoft Build of OpenJDK 25.0.5.0.2 (full JDK) + GNU General Public License, version 2, with the Classpath Exception; + included components retain their own notices + https://learn.microsoft.com/java/openjdk/download + https://learn.microsoft.com/java/openjdk/faq + https://github.com/microsoft/openjdk-jdk25u/tree/release/jdk-25.0.5.0.2_1 + +The managed dependency versions, immutable URLs and SHA-256 checksums are +recorded in io.github.lithe-idea.java-support/plugin.json. This Apache License +for the plugin does not replace the licenses of those dependencies. The icons java.svg and java_dark.svg in io.github.lithe-idea.java-support/icons/ come from the JetBrains IntelliJ Platform diff --git a/README.md b/README.md index 81fcab0..a666a95 100644 --- a/README.md +++ b/README.md @@ -6,9 +6,7 @@ > (Web App Libraries、EAR Libraries、Server Runtime)、IntelliJ IDEA 的模块与库,以及传统 Web 的 `WEB-INF/lib`, > 在内存中补全类路径并自动找到 Tomcat 等 Servlet 容器,不修改项目文件,详见 [docs/project-models.md](docs/project-models.md)。 > -> **3.0.0 起使用你自己的 JDT LS**:插件包不再附带 Eclipse JDT Language Server 和运行它的 JDK(包从约 250 MB 降到约 11 MB), -> 做法和 Go 插件使用你自己的 `gopls` 一样。需要先安装 JDT LS(例如 `brew install jdtls`)和 JDK 21 或更新版本, -> 详见下文[语言服务器与 JDK](#语言服务器与-jdk)。 +> **自动准备 Java 语言服务环境**:安装时分别检查完整 JDK 25 和固定的 JDT LS 1.61.0,只下载缺少或不兼容的部分。运行环境保存在插件包之外,后续插件更新复用同一份缓存;项目自己的 JDK 独立选择。需要同时支持 `managedRuntimes` 0 的配套 Lithe / Core,详见[语言服务器与 JDK](#语言服务器与-jdk)和[实现与验证](docs/managed-runtimes.md)。 > **Viva 预览版 Java 支持(1.2.0)**:清单已迁到当前契约 0,后端使用 Core > `65cf82343c5e315aae2e335b2e8f0217b703e89a` 中的 Rust SDK 0.4.0(尚无对应发布标签)。 @@ -23,12 +21,12 @@ [Lithe](https://github.com/1lck/Lithe-IDEA) 的 Java 插件(`io.github.lithe-idea.java-support`): -用你电脑上的 Eclipse JDT Language Server,加上随包的 Lombok、java-debug、vscode-java-test 扩展, +使用自动准备或经校验复用的 Eclipse JDT Language Server,加上随包的 Lombok、java-debug、vscode-java-test 扩展, 为 Java 项目提供补全、诊断、导航、运行/调试入口、测试运行和 Spring Boot / MyBatis 索引。 它是普通插件(vendor 为 `Lithe Community`),插件包不带发布者签名。 > English: The Java plugin for Lithe, a regular plugin (vendor `Lithe Community`) whose package carries no publisher -> signature. It runs your own Eclipse JDT LS on your own JDK 21+, adds the packaged Lombok, java-debug and +> signature. It prepares the pinned Eclipse JDT LS and a separate full JDK 25, reuses compatible installations, and adds the packaged Lombok, java-debug and > vscode-java-test extensions, and provides Java language features, run/debug entry points, test runs and Spring Boot / > MyBatis indexes. The Java rules live in a Rust domain crate and a plugin backend built on the published Lithe Rust plugin > SDK. Maven and Gradle import settings come from the Maven and Gradle plugins through a function interface that @@ -53,7 +51,9 @@ `.jsp` 仍按 HTML 打开;Java 补全、跳转和 JSP 源码断点不属于此次新增能力。 -## 当前 Viva 验证入口 +## 既有 Viva 工作流验证记录 + +本节保留此前版本的工作流与性能记录;新的运行环境准备、缓存和平台验收以 [managed-runtimes.md](docs/managed-runtimes.md) 为准。 先用 `scripts/build-package.sh --arch arm64` 与 `scripts/archive-package.sh` 构建真实插件包。 在包含配套修复的 Lithe 检出中,把 `LITHE_TEST_JAVA_PLUGIN_ARCHIVE` 指向该 ZIP, @@ -169,7 +169,8 @@ Spring/MyBatis 等既有能力不属于本轮 Maven 验收范围。 | `documents.read` | 读取当前 Java 文档以收集动作 | | `documents.contentProvider` | 提供 JDT 虚拟源码 | | `editor.actions` | 注册 Run/Debug 行内动作 | -| `languageServer.launch` | 启动包内 JDT LS | +| `languageServer.launch` | 启动经过准备的 JDT LS | +| `runtimes.install` | 由宿主下载并缓存清单固定来源、固定校验和的语言服务依赖 | | `languageServer.request` | JDT 构建、main、测试、类路径和调试扩展请求 | | `project.generate` | 既有 Java/Spring Boot 生成器 | | `debug.launch`、`debug.attach`、`debug.start` | 声明 java-debug 适配器并经 Run 工作流发起调试 | @@ -185,7 +186,7 @@ Spring/MyBatis 等既有能力不属于本轮 Maven 验收范围。 | 功能 | 说明 | | --- | --- | -| 语言服务 | 用你电脑上的 JDT LS(加上随包的 Lombok)提供补全、诊断、导航;运行它的 JDK 21+ 和项目自己的 JDK 分别选择 | +| 语言服务 | 使用固定 JDT LS 1.61.0 和独立的完整 JDK 25;缺失依赖自动准备,已有兼容安装复用;项目 JDK 单独选择 | | 运行与调试 | 在 `main` 方法和测试旁显示 Run/Debug 行内动作;点击后后端经 JDT LS 构建并解析类路径,用用户选择的 JDK 通过宿主 Run 窗口启动,调试经 java-debug 连接;当前 Viva 包暂不提供控制台堆栈链接 | | 测试 | 发现 JUnit/TestNG 测试项,按类或方法启动 Eclipse JUnit 运行器(TestNG 用 vscode-java-test 运行器),运行结束后显示通过/失败计数 | | Spring Boot / MyBatis | 索引 Spring 端点与 MyBatis 映射,支持跳转 | @@ -194,33 +195,35 @@ Spring/MyBatis 等既有能力不属于本轮 Maven 验收范围。 ## 语言服务器与 JDK -插件包不带 JDT LS,也不带运行它的 JDK,和 Go 插件使用你自己的 `gopls` 一样。需要: +安装 Java 支持时,宿主先调用插件的只读 `java.resolveRuntimes` 检查两个独立依赖,再下载缺少的部分。插件 ZIP 继续只包含 Rust 后端、配置、Lombok 和 JDT 扩展,不把大型运行环境重复放进每次插件更新。 + +| 本机可复用的依赖 | 安装时需要下载 | +| --- | --- | +| 完整 JDK 25 和匹配的 JDT LS 1.61.0 | 无 | +| 只有完整 JDK 25 | JDT LS | +| 只有匹配的 JDT LS 1.61.0 | 完整 JDK 25 | +| 两者都缺少或不兼容 | 两者 | + +默认下载为 **Microsoft Build of OpenJDK 25.0.5.0.2(完整 JDK)**和 **Eclipse JDT LS 1.61.0**。每个平台的固定 HTTPS 地址、SHA-256、解包根目录都在 `plugin.json`;JDT LS 与随包扩展共用 `third_party/jdtls/manifest.json` 的版本基线。没有使用滚动的 latest 下载地址。 + +运行环境位于插件的独立 `state/runtimes`,以依赖、版本、平台和校验和识别,与插件版本目录分开。后续更新若依赖 pin 不变,会复用缓存;只修改其中一个依赖时,只准备那个依赖。下载或解包失败不会发布半成品,已经准备好的安装保留。缓存损坏会重新准备;卸载插件会清理它的状态和运行环境。旧运行环境世代暂不自动清理,避免影响仍在运行的进程和失败回滚。 + +仍可手动选择安装: -1. **Eclipse JDT Language Server**。按以下顺序找,优先使用当前 `jdtls-runtime` 可满足其最低 Java 版本要求的安装;若都不满足则落到第一个并报出该安装所需的最低 Java 版本: - 1. 设置 → 语言与框架 → Java →「语言服务器目录」。选了目录就只用它,目录里没有 JDT LS 时直接报错,不会退回别的安装; - 2. 环境变量 `JDTLS_HOME`; - 3. `PATH` 上的 `jdtls` 启动脚本所属的安装(沿符号链接找到真实目录); - 4. Homebrew(`/opt/homebrew/opt/jdtls`、`/usr/local/opt/jdtls`)、Linuxbrew、mason.nvim、Scoop 的安装目录; - 5. VS Code 及其衍生编辑器里 Java 扩展(`redhat.java`)自带的 `server/`,取最新版本。 +- **JDT LS**:设置 → 语言与框架 → Java →「语言服务器目录」。显式选择会检查完整 bundle 集合与当前平台配置的 SHA-256,必须匹配本插件验证的 1.61.0。目录不兼容时直接提示修正,不会忽略设置。留空时先复用缓存,再检查 `JDTLS_HOME`、`PATH`、Homebrew、Linuxbrew、mason.nvim、Scoop 和 VS Code Java 扩展中的服务器;这些位置找到的其他版本不会被当作兼容版本。 +- **运行 JDT LS 的 JDK**:工具链中的「JDK for JDT LS」(`jdtls-runtime`)。必须是当前平台的完整 JDK 25,包含可执行的 `java`、`javac`、模块镜像和 `jmods`;JRE、早期访问版本、其他大版本和不完整安装不能复用。自动准备只绑定此工具,不设置全局 `JAVA_HOME`。 +- **项目 JDK**:原有「JDK」(`java`)继续独立选择,项目仍可使用 Java 8、11、17、21 等受项目构建支持的版本。选择语言服务 JDK 25 不会修改项目的 source/target/release、Maven/Gradle 设置或运行 JDK。未选择项目 JDK 时,JDT 自身的默认行为仍可能使用服务 JDK;旧项目应明确选择项目运行环境。 - 目录(或其中的 `libexec/`)里要有唯一一个 `plugins/org.eclipse.equinox.launcher_*.jar` 和当前平台的 - `config_<平台>/config.ini`。安装方式举例:macOS / Linux 用 `brew install jdtls`;也可以从 - [download.eclipse.org/jdtls](https://download.eclipse.org/jdtls/milestones/) 下载解压,再在设置里选目录。 - 已测试 JDT LS 1.61.0(CI 固定,见 `third_party/jdtls/manifest.json`)和 Homebrew 1.60.0。 -2. **满足目标 JDT LS 要求的 JDK(至少 JDK 21;JDT LS 1.63+ 要求 JDK 25)**,用来运行 JDT LS。它是插件新增的「JDK for JDT LS」工具(`jdtls-runtime`), - 在设置 → 构建、执行、部署 → 工具链里显示和选择;没选时依次用登录 shell 的 `java`(仅匹配 21 及更新版本,跳过 `PATH` 上的 Java 8/11/17)和找到的最高版本 JDK(含系统 JDK 目录与 VS Code / Cursor `redhat.java` 扩展自带的 `jre/`)。 - 后端会从目标 JDT LS 核心 bundle 的 `MANIFEST.MF`(`Bundle-RequiredExecutionEnvironment`)读取实际最低 Java 版本,低于该版本时启动直接报错并提示去工具链里选择。项目自己的 JDK 是原来的「JDK」工具(`java`),两者互不影响。 - JDT 只能为它支持的 Java 版本编译:没有为项目选 JDK 时,JDT 用运行它的 JDK 编译,这个 JDK 比 JDT LS 支持的最新 Java 还新时编译会报错。 +首次准备需要访问清单中的官方下载源;环境齐全后不再为启动语言服务联网。Maven/Gradle 项目依赖的下载仍由各自工具和设置控制。自动配齐环境解决启动依赖缺失、路径与版本混装等问题;它不能自动修复错误的项目模型、私有仓库认证、项目依赖或上游 JDT 兼容性缺陷。 -找不到 JDT LS 时,语言服务启动失败(`launch.server_missing`),错误信息说明如何安装或去哪里设置。 -宿主当前的 `commandInstallers` 只能安装 `systemCommand` 启动的命令,JDT LS 由插件后端启动,所以还不能像 Go 插件那样在插件详情里一键安装。 +六个平台都有官方完整 JDK 下载声明;这不代表六个平台的插件都已实机验收。Windows ARM64 原生插件包仍以宿主和后端发布支持为前提,见[验证矩阵](docs/feature-matrix.md)。 ## 工作方式 - Java 专属的 URI、JDT 初始化、编译/运行/调试和长 classpath 规划属于本插件及成熟上游;宿主只提供通用服务。 Maven / Gradle 自己解析配置,通过 `languageImport.settings` 接口提供 JDT 导入设置,Java 不维护第二套构建模型。 -- `backend/src/jdtls.rs` 找到你安装的 JDT LS,`backend/src/launch.rs` 加上随包的 Lombok、java-debug、java-test, - 用 `jdtls-runtime` 工具(JDK 21+)启动它。宿主传入用户所选项目 JDK 的安装事实,插件据此设置 JDT 运行时; +- `backend/src/managed_runtimes.rs` 校验并选择依赖,宿主负责缺失依赖的下载和原子安装;`backend/src/launch.rs` 使用批准的运行环境映射,加上随包的 Lombok、java-debug、java-test, + 用独立的 `jdtls-runtime` 工具(完整 JDK 25)启动它。宿主传入用户所选项目 JDK 的安装事实,插件据此设置 JDT 运行时; 运行 JDT LS 的 JDK 不代替项目的目标版本。 - 初始化就绪不等于索引完成。JDT 公开的 `progressReportProvider` 扩展将完成事件发到已声明的 `language/progressReport` 通道。只有动作查询发生瞬态失败才在完成边界刷新;同时处理完成与超时倒序, @@ -228,7 +231,7 @@ Spring/MyBatis 等既有能力不属于本轮 Maven 验收范围。 - Windows 使用原生 `java.exe`,文件 URI 由 `url` crate 处理,包路径通过 `dunce` 去除可安全简化的 verbatim 前缀, 避免 Lombok 的 `-javaagent` 加载失败。过长 classpath 复用领域层的 manifest JAR 规划,适用于 Java 8 及更新版本; ASCII 百分号编码覆盖中文/空格,宿主写入临时 JAR 并在运行结束删除。长 module-path 尚未覆盖。 -- 已安装插件包和你的 JDT LS 安装始终只读。JDT 配置副本(从安装里的 `config_<平台>/config.ini` 复制)、索引、日志、锁和临时文件 +- 已安装插件包、JDT LS 和完整 JDK 安装始终只读。JDT 配置副本(从安装里的 `config_<平台>/config.ini` 复制)、索引、日志、锁和临时文件 写到宿主提供的用户状态/缓存/临时目录;插件包、JDT LS 安装、app bundle 和 Windows 安装目录不作为可写目标。 随包扩展在构建期固定来源、校验哈希,运行期不下载。 @@ -245,7 +248,8 @@ Spring/MyBatis 等既有能力不属于本轮 Maven 验收范围。 | 其余函数成功(编辑器驱动或启动时的读取,如 `java.runMarkers`、`java.codeVision`、`spring.index`) | 不记录 | `suppress_success_diagnostics`(`backend/src/lib.rs`) | — | | 任一函数失败 | ERROR | SDK 自动 | 类别为 `pluginErrorCode`(如 `java.invalidRequest`;`languageImport.settingsChanged` 的 `relay.caller_missing`、`relay.context_missing`、`relay.invalid_params`)、耗时;不含消息与 `details` | | 领域命令失败类别 | ERROR | `plugin_error_code` | `java.invalidRequest`、`java.workspaceNotFound`、`java.permissionDenied`、`java.notSupported`、`java.runtimeMissing`、`java.processStartFailed`、`java.processFailed`、`java.parseFailed`、`java.cancelled`、`java.timedOut`、`java.connectionClosed`、`java.unknown`;SDK 识别的取消不记录 | -| JDT 启动规划失败 | ERROR | SDK 自动 | `launch.invalid_params`、`launch.package_unavailable`、`launch.resource_missing`、`launch.configuration_failed`、`launch.server_missing`(找不到 JDT LS)、`launch.server_invalid`(设置的目录不是 JDT LS)、`launch.runtime_too_old`(运行 JDT LS 的 JDK 低于目标 JDT LS 要求的最低版本,至少 21) | +| JDT 启动规划失败 | ERROR | SDK 自动 | `launch.invalid_params`、`launch.package_unavailable`、`launch.resource_missing`、`launch.configuration_failed`、`launch.runtime_too_old`(语言服务 JDK 低于本插件要求的 25);运行环境问题使用下行类别 | +| 运行环境准备失败 | ERROR | SDK 自动 | `runtime.invalid_params`、`runtime.server_incompatible`、`runtime.jdk_invalid`、`runtime.not_prepared`、`runtime.profile_invalid`;缺少自动准备的依赖属于正常计划,不记录错误,成功读取不记录 INFO;恢复提示随界面语言中英切换 | | JDT 配置清理或工作区读取降级 | WARN | SDK `degraded` | `launch.configuration_cleanup_failed`、`launch.workspace_folders_unavailable` | | 取消 | 不记录 | SDK | — | | 列出 `languageImport.settings` 提供方失败、单个提供方失败或超时、答复不可用、答复含越界键、提供方导出的函数版本不符 | WARN(`degraded`) | `backend/src/plugin_functions.rs` | 类别 `relay.providers_unavailable`、`relay.provider_failed`、`relay.provider_timed_out`、`relay.settings_rejected`、`relay.keys_rejected`、`relay.provider_version_mismatch`,计数;不含提供方 ID | diff --git a/backend/Cargo.toml b/backend/Cargo.toml index b3073fc..aae120d 100644 --- a/backend/Cargo.toml +++ b/backend/Cargo.toml @@ -26,3 +26,6 @@ java-properties = "2.0.0" xmltree = { version = "0.12.0", features = ["attribute-order"] } jsonc-parser = { version = "0.34.0", features = ["cst", "serde"] } libc = "0.2" + +[dev-dependencies] +regex.workspace = true diff --git a/backend/src/jdtls.rs b/backend/src/jdtls.rs index e39c9d2..ff00c05 100644 --- a/backend/src/jdtls.rs +++ b/backend/src/jdtls.rs @@ -1,32 +1,18 @@ //! Finds the Eclipse JDT Language Server installed on the user's machine. //! -//! The plugin package does not ship JDT LS or a Java runtime for it, the same -//! way the Go plugin uses the user's own `gopls`: the user installs JDT LS -//! with a package manager or an editor, and the launch reads its files from -//! there. The backend only reads that installation. Equinox gets a writable -//! copy of the installation's `config.ini` under the host's state directory -//! (`prepare_jdt_configuration_area`), so neither the backend nor JDT LS -//! writes into the user's installation. +//! These read-only discovery helpers enumerate external installations. The +//! managed-runtime hook in [`crate::managed_runtimes`] applies the stricter +//! pinned-file qualification before reusing one. Missing dependencies are +//! downloaded by the host into separate state, never into the plugin package. //! -//! # Where the launch looks +//! The discovery order is `JDTLS_HOME`, a `jdtls` launcher on `PATH`, common +//! package managers (Homebrew, Linuxbrew, mason.nvim, Scoop), then installed +//! VS Code Java extensions. An explicit `languageServerHome` is final. //! -//! [`locate`] takes the first installation of these, in order: -//! -//! 1. the `languageServerHome` setting. A folder set there is the user's -//! explicit choice, so an unusable one fails the launch instead of falling -//! back to another installation; -//! 2. the `JDTLS_HOME` environment variable; -//! 3. a `jdtls` launcher on `PATH`, resolved through its symbolic links to the -//! installation it belongs to; -//! 4. the folders package managers install JDT LS into (Homebrew, Linuxbrew, -//! mason.nvim, Scoop); -//! 5. the language server inside an installed VS Code Java extension -//! (`redhat.java`), newest version first. -//! -//! A folder holds an installation when it, or its `libexec/` (Homebrew keeps -//! the files there), contains exactly one Equinox launcher JAR in `plugins/` -//! and the `config_/config.ini` of the host platform. Nothing else -//! is checked: JDT LS reports a version it cannot run at `initialize`. +//! [`inspect`] recognizes the basic launcher/configuration layout only. It +//! does not assert compatibility with the plugin; the managed hook verifies +//! the complete bundle set and platform template against the pinned archive. +//! Mutable Equinox configuration is copied into host-provided state. use lithe_plugin_sdk::PluginError; use std::ffi::OsString; diff --git a/backend/src/launch.rs b/backend/src/launch.rs index 7048842..dd972bf 100644 --- a/backend/src/launch.rs +++ b/backend/src/launch.rs @@ -10,12 +10,11 @@ //! //! # Where the files are //! -//! JDT LS itself is not in the package: [`crate::jdtls`] finds the -//! installation on the machine, the way the Go plugin uses the user's own -//! `gopls`. The answer runs it with the plugin's `jdtls-runtime` tool -//! ([`SERVER_RUNTIME_TOOL`]), a JDK the host resolves from the user's choice -//! and discovery, and refuses one older than -//! [`MINIMUM_SERVER_JAVA_VERSION`] when the host reports its version. +//! JDT LS and its JDK live outside the small plugin package. The host prepares +//! the dependencies declared in `managedRuntimes`; [`crate::managed_runtimes`] +//! qualifies existing files before any missing dependency is downloaded. The +//! launch uses that approved server home and the separate `jdtls-runtime` +//! tool ([`SERVER_RUNTIME_TOOL`]). The project's `java` tool stays independent. //! //! The package only carries what the plugin adds to JDT LS: the Lombok agent //! and the Java Debug and Java Test extension bundles. `resolveParams` carries @@ -49,9 +48,9 @@ //! [`settings_session::java_configuration`]: crate::settings_session::java_configuration use crate::jdtls::{ - self, SearchEnvironment, ServerInstallation, LAUNCH_SERVER_INVALID, LAUNCH_SERVER_MISSING, - SERVER_HOME_SETTING, + ServerInstallation, LAUNCH_SERVER_INVALID, LAUNCH_SERVER_MISSING, SERVER_HOME_SETTING, }; +use crate::managed_runtimes; use crate::project_model::{ModelOptions, ProjectModel}; use crate::run::file_uri; use crate::settings_session::{java_configuration, jdt_settings, SettingsSession, SERVER_ID}; @@ -104,13 +103,13 @@ pub const LAUNCH_ERROR_CODES: &[&str] = &[ /// JDT LS accepts. pub const SERVER_RUNTIME_TOOL: &str = "jdtls-runtime"; /// Oldest Java feature release JDT LS runs on. -pub const MINIMUM_SERVER_JAVA_VERSION: u64 = 21; +pub const MINIMUM_SERVER_JAVA_VERSION: u64 = managed_runtimes::JAVA_FEATURE; /// Message of [`LAUNCH_RUNTIME_TOO_OLD`] for [`MINIMUM_SERVER_JAVA_VERSION`]. /// /// TODO(host-api: API-37 i18n): user-facing text must go through the host's /// i18n table. -pub const RUNTIME_TOO_OLD_MESSAGE: &str = "The Eclipse JDT Language Server needs Java 21 or \ -later, but the JDK chosen for it is older. Choose a JDK 21 or later for \"JDK for JDT LS\" in \ +pub const RUNTIME_TOO_OLD_MESSAGE: &str = "The Eclipse JDT Language Server needs Java 25 or \ +later, but the JDK chosen for it is older. Choose a JDK 25 or later for \"JDK for JDT LS\" in \ Settings > Build, Execution, Deployment > Toolchains."; /// Message of [`LAUNCH_RUNTIME_TOO_OLD`] for the Java feature release @@ -254,8 +253,8 @@ pub struct LaunchRequest { pub heap_max_mb: u64, /// `settings.logLevel`: the JDT LS log level. pub log_level: String, - /// `settings.languageServerHome`: the JDT LS folder the user chose; - /// `None` finds one ([`crate::jdtls::locate`]). + /// Explicit `settings.languageServerHome`, otherwise the approved + /// `runtimes.jdtls.home`. No launch-time rediscovery can replace it. pub server_home: Option, /// `tools["jdtls-runtime"].version`, when the host resolved the JDK that /// runs JDT LS and read its version. @@ -330,6 +329,17 @@ pub fn parse_launch_params(params: &Value) -> Result } }, }; + let prepared_home = match params.get("runtimes").and_then(|value| value.get("jdtls")) { + None => None, + Some(value) => Some( + value + .get("home") + .and_then(Value::as_str) + .map(PathBuf::from) + .filter(|home| home.is_absolute()) + .ok_or_else(|| invalid_params("The prepared language server folder is invalid."))?, + ), + }; let model_options = crate::project_model::parse_options(&settings).map_err(invalid_params)?; Ok(LaunchRequest { os: os.to_string(), @@ -340,7 +350,7 @@ pub fn parse_launch_params(params: &Value) -> Result temporary_directory: directory(params, "temporaryDirectory")?, heap_max_mb, log_level: log_level.to_string(), - server_home, + server_home: server_home.or(prepared_home), server_runtime_version: host_tool_version(params, SERVER_RUNTIME_TOOL), java_runtimes: jdt_java_runtimes(&host_java_tool(params)), model_options, @@ -726,13 +736,15 @@ pub fn resolve_launch_function( context.check_cancelled()?; let request = parse_launch_params(¶ms)?; check_server_runtime(&request)?; - let server = jdtls::locate_for_runtime( - request.server_home.as_deref(), - &SearchEnvironment::current(), - &request.os, - &request.architecture, - server_runtime_feature(&request), - )?; + let home = request + .server_home + .as_deref() + .ok_or_else(managed_runtimes::not_prepared)?; + let server = + managed_runtimes::inspect_server(home, &request.os, &request.architecture, &|| { + context.check_cancelled().map_err(Into::into) + })? + .ok_or_else(managed_runtimes::incompatible_server)?; let package_root = package_root()?; let diagnostics = context.diagnostics(); let operation = context.function_id().to_owned(); @@ -788,6 +800,7 @@ pub fn resolve_launch_function( #[cfg(test)] mod tests { use super::*; + use crate::jdtls; #[test] #[cfg(windows)] @@ -1194,14 +1207,16 @@ mod tests { } #[test] - fn a_runtime_older_than_java_21_is_refused_before_anything_is_written() { + fn a_runtime_older_than_java_25_is_refused_before_anything_is_written() { let fixture = Fixture::new(); let mut params = fixture.params(); for (version, accepted) in [ ("17.0.19", false), ("8.0.392", false), - ("21", true), - ("21.0.9", true), + ("21", false), + ("21.0.9", false), + ("25", true), + ("25.0.5.0.2", true), ("26.0.2", true), ("unknown", true), ] { diff --git a/backend/src/lib.rs b/backend/src/lib.rs index a991261..78b3a58 100644 --- a/backend/src/lib.rs +++ b/backend/src/lib.rs @@ -16,7 +16,8 @@ //! The manifest declares the `java` language server with //! `launch.kind: "backend"`, so the host asks [`launch`] for the JDT LS //! command line, initialization options and startup settings before each -//! start. JDT LS is the user's own installation, which [`jdtls`] finds. +//! start. [`managed_runtimes`] qualifies the separately installed JDT LS +//! and full JDK; the host downloads only missing declared dependencies. //! The launch reads the settings the [`settings_session`] knows for //! the workspace, so a restart starts with the last pushed settings. //! @@ -52,6 +53,7 @@ pub mod class_content; pub mod jdtls; pub mod launch; pub mod library_settings; +pub mod managed_runtimes; pub mod module_structure; pub mod plugin_functions; pub mod project_model; @@ -188,6 +190,13 @@ pub fn backend() -> Result { Ok(plan) } })?; + backend.function( + managed_runtimes::RESOLVE_FUNCTION_ID, + managed_runtimes::resolve_runtimes_function, + )?; + // Cache qualification is a startup read, including an expected missing + // dependency. The SDK still records failures of explicit configuration. + backend.suppress_success_diagnostics(managed_runtimes::RESOLVE_FUNCTION_ID)?; // The run session registers the editor actions of every workspace context // and keeps the result listener of each test run; both happen outside a @@ -428,6 +437,7 @@ mod tests { .chain(plugin_functions::RELAY_CATEGORIES) .chain(launch::LAUNCH_ERROR_CODES) .chain(launch::LAUNCH_CATEGORIES) + .chain(managed_runtimes::ERROR_CODES) .chain(run::RUN_ERROR_CODES) .chain(run::RUN_CATEGORIES) { diff --git a/backend/src/managed_runtimes.rs b/backend/src/managed_runtimes.rs new file mode 100644 index 0000000..86c05df --- /dev/null +++ b/backend/src/managed_runtimes.rs @@ -0,0 +1,873 @@ +//! Read-only qualification of the Java plugin's managed dependencies. +//! +//! The host owns downloads, archive verification, atomic installation and +//! cache lifetime. This function only chooses installations that can run the +//! plugin's pinned extensions. It never downloads, writes to an installation, +//! or executes a candidate program. The project `java` tool is never changed. + +use crate::jdtls::{self, SearchEnvironment, ServerInstallation, SERVER_HOME_SETTING}; +use crate::launch::SERVER_RUNTIME_TOOL; +use lithe_plugin_sdk::{Context, FunctionError, PluginError, Value}; +use serde_json::json; +use sha2::{Digest, Sha256}; +use std::collections::BTreeSet; +use std::fs::{self, File}; +use std::io::{Read, Seek, SeekFrom}; +use std::path::{Path, PathBuf}; + +/// Backend hook used by the host's generic managed-runtime installer. +pub const RESOLVE_FUNCTION_ID: &str = "java.resolveRuntimes"; +/// Dependency ID of the full JDK used only by the language server. +pub const JDK_ID: &str = "jdk"; +/// Dependency ID of the upstream Eclipse JDT LS installation. +pub const JDTLS_ID: &str = "jdtls"; +/// The Java feature release verified with the pinned JDT LS and extensions. +pub const JAVA_FEATURE: u64 = 25; +/// Version of the full Microsoft Build of OpenJDK installed when none qualifies. +pub const JDK_VERSION: &str = "25.0.5.0.2"; +/// The request does not match the plugin's declared dependency contract. +pub const INVALID_PARAMS: &str = "runtime.invalid_params"; +/// An explicitly selected server is not the verified upstream distribution. +pub const SERVER_INCOMPATIBLE: &str = "runtime.server_incompatible"; +/// The explicitly selected service tool is not a usable full Java 25 JDK. +pub const JDK_INVALID: &str = "runtime.jdk_invalid"; +/// The host has not prepared the runtime map required for this launch. +pub const NOT_PREPARED: &str = "runtime.not_prepared"; +/// The compiled upstream fingerprint is invalid; reinstalling repairs it. +pub const PROFILE_INVALID: &str = "runtime.profile_invalid"; +/// Error categories reported by the SDK for runtime resolution. +pub const ERROR_CODES: &[&str] = &[ + INVALID_PARAMS, + SERVER_INCOMPATIBLE, + JDK_INVALID, + NOT_PREPARED, + PROFILE_INVALID, +]; + +const PROFILE: &str = include_str!("../../third_party/jdtls/runtime-files.json"); +const MAX_DISCOVERED_SERVERS: usize = 32; +const MAX_RELEASE_BYTES: u64 = 64 * 1024; + +#[derive(Debug)] +struct PinnedFile { + path: PathBuf, + size: u64, + sha256: String, +} + +#[derive(Debug)] +struct ServerProfile { + version: String, + files: Vec, + configurations: Vec<(String, PinnedFile)>, +} + +impl ServerProfile { + fn parse(text: &str) -> Option { + let value: Value = serde_json::from_str(text).ok()?; + let file = |value: &Value| -> Option { + let path = PathBuf::from(value.get("path")?.as_str()?); + if path.is_absolute() + || path + .components() + .any(|part| !matches!(part, std::path::Component::Normal(_))) + { + return None; + } + let sha256 = value.get("sha256")?.as_str()?; + if sha256.len() != 64 || !sha256.bytes().all(|byte| byte.is_ascii_hexdigit()) { + return None; + } + Some(PinnedFile { + path, + size: value.get("size")?.as_u64()?, + sha256: sha256.to_owned(), + }) + }; + let files: Vec<_> = value + .get("files")? + .as_array()? + .iter() + .map(file) + .collect::>()?; + if files.is_empty() || files.len() > 1024 { + return None; + } + let configurations = value + .get("configurations")? + .as_object()? + .iter() + .map(|(name, value)| Some((name.clone(), file(value)?))) + .collect::>()?; + Some(Self { + version: value.get("version")?.as_str()?.to_owned(), + files, + configurations, + }) + } + + fn pinned() -> Result { + Self::parse(PROFILE).ok_or_else(|| { + PluginError::new( + PROFILE_INVALID, + "Java Support cannot read its runtime requirements. Reinstall the plugin.", + ) + }) + } +} + +fn invalid() -> PluginError { + PluginError::new( + INVALID_PARAMS, + "Java Support received invalid runtime preparation parameters.", + ) +} + +/// Error for an explicit installation that does not match the verified set. +pub fn incompatible_server() -> PluginError { + PluginError::new( + SERVER_INCOMPATIBLE, + "The selected language server does not match the verified JDT LS 1.61.0 files. \ +Choose that release or clear Language server folder so Lithe can prepare it automatically.", + ) +} + +/// Error used instead of silently rediscovering a server after preparation. +pub fn not_prepared() -> PluginError { + PluginError::new( + NOT_PREPARED, + "The Java language service environment is not ready. Retry Java Support environment preparation.", + ) +} + +fn absolute(value: Option<&Value>) -> Option { + value + .and_then(Value::as_str) + .map(PathBuf::from) + .filter(|path| path.is_absolute()) +} + +fn release_value<'a>(release: &'a str, key: &str) -> Option<&'a str> { + release.lines().find_map(|line| { + let (name, value) = line.split_once('=')?; + (name == key).then(|| value.trim().trim_matches('"')) + }) +} + +fn java_25(version: &str) -> bool { + !version.contains("-ea") + && version + .split(['.', '+', '-', '_']) + .next() + .and_then(|feature| feature.parse::().ok()) + == Some(JAVA_FEATURE) +} + +fn regular_nonempty(path: &Path) -> bool { + fs::metadata(path).is_ok_and(|metadata| metadata.is_file() && metadata.len() > 0) +} + +/// Checks native launcher headers without executing any candidate Java. +/// The release file alone can survive a partial extraction or point at a +/// different architecture; the Java and javac launchers must agree with it. +fn native_launcher(path: &Path, os: &str, arch: &str) -> bool { + let Ok(metadata) = fs::metadata(path) else { + return false; + }; + if !metadata.is_file() || metadata.len() < 4096 { + return false; + } + #[cfg(unix)] + if os != "windows" { + use std::os::unix::fs::PermissionsExt; + if metadata.permissions().mode() & 0o111 == 0 { + return false; + } + } + let Ok(mut file) = File::open(path) else { + return false; + }; + let mut bytes = [0u8; 512]; + if file.read_exact(&mut bytes).is_err() { + return false; + } + let little32 = |offset| { + u32::from_le_bytes( + bytes[offset..offset + 4] + .try_into() + .expect("four header bytes"), + ) + }; + match os { + "linux" => { + bytes[..6] == [0x7f, b'E', b'L', b'F', 2, 1] + && u16::from_le_bytes([bytes[18], bytes[19]]) + == if arch == "arm64" { 183 } else { 62 } + } + "macos" => { + let cpu = if arch == "arm64" { + 0x0100000c + } else { + 0x01000007 + }; + if bytes[..4] == [0xcf, 0xfa, 0xed, 0xfe] { + return little32(4) == cpu; + } + let width = match bytes[..4] { + [0xca, 0xfe, 0xba, 0xbe] => 20, + [0xca, 0xfe, 0xba, 0xbf] => 32, + _ => return false, + }; + let count = u32::from_be_bytes(bytes[4..8].try_into().expect("four header bytes")); + count <= 12 + && (0..count as usize).any(|index| { + let start = 8 + index * width; + u32::from_be_bytes( + bytes[start..start + 4] + .try_into() + .expect("four header bytes"), + ) == cpu + }) + } + "windows" => { + if bytes[..2] != *b"MZ" { + return false; + } + let offset = little32(60) as u64; + let mut header = [0u8; 6]; + offset <= 1024 * 1024 + && file.seek(SeekFrom::Start(offset)).is_ok() + && file.read_exact(&mut header).is_ok() + && header[..4] == *b"PE\0\0" + && u16::from_le_bytes([header[4], header[5]]) + == if arch == "arm64" { 0xaa64 } else { 0x8664 } + } + _ => false, + } +} + +/// Qualifies a full JDK 25, returning its canonical home and release version. +/// A JRE (no javac/jmods), early-access build, wrong architecture, empty or +/// non-native launcher and partial archive are not reusable. +pub fn inspect_jdk(home: &Path, os: &str, arch: &str) -> Option<(PathBuf, String)> { + let home = dunce::canonicalize(home).ok()?; + let mut release = String::new(); + File::open(home.join("release")) + .ok()? + .take(MAX_RELEASE_BYTES) + .read_to_string(&mut release) + .ok()?; + let version = release_value(&release, "JAVA_VERSION")?; + if !java_25(version) { + return None; + } + let reported_arch = release_value(&release, "OS_ARCH")?; + if !matches!( + (arch, reported_arch), + ("arm64", "aarch64" | "arm64") | ("x86_64", "amd64" | "x86_64" | "x64") + ) { + return None; + } + let reported_os = release_value(&release, "OS_NAME")?; + if !matches!( + (os, reported_os), + ("linux", "Linux") | ("macos", "Darwin" | "macOS") | ("windows", "Windows" | "Windows_NT") + ) { + return None; + } + let suffix = if os == "windows" { ".exe" } else { "" }; + if !["java", "javac"] + .iter() + .all(|name| native_launcher(&home.join(format!("bin/{name}{suffix}")), os, arch)) + || !regular_nonempty(&home.join("lib/modules")) + || !regular_nonempty(&home.join("jmods/java.base.jmod")) + { + return None; + } + Some((home, version.to_owned())) +} + +fn matches_file(home: &Path, pin: &PinnedFile) -> bool { + let path = home.join(&pin.path); + if !fs::metadata(&path).is_ok_and(|metadata| metadata.is_file() && metadata.len() == pin.size) { + return false; + } + let Ok(file) = File::open(path) else { + return false; + }; + let mut file = file.take(pin.size.saturating_add(1)); + let mut hash = Sha256::new(); + let mut bytes = [0u8; 64 * 1024]; + loop { + match file.read(&mut bytes) { + Ok(0) => break, + Ok(count) => hash.update(&bytes[..count]), + Err(_) => return false, + } + } + format!("{:x}", hash.finalize()) == pin.sha256 +} + +fn inspect_server_with( + home: &Path, + os: &str, + arch: &str, + profile: &ServerProfile, + check_cancelled: &dyn Fn() -> Result<(), FunctionError>, +) -> Result, FunctionError> { + let Some(configuration) = jdtls::configuration_name(os, arch) else { + return Ok(None); + }; + let Some(server) = jdtls::inspect(home, configuration) else { + return Ok(None); + }; + // Additional bundles can change Equinox's resolution even when every + // pinned jar remains present. Qualify the complete flat bundle set, + // not only the core jar's version or a subset of matching files. + let expected: BTreeSet<_> = profile + .files + .iter() + .filter_map(|pin| pin.path.strip_prefix("plugins").ok()) + .map(Path::to_path_buf) + .collect(); + let Ok(entries) = fs::read_dir(server.home.join("plugins")) else { + return Ok(None); + }; + let actual = entries + .take(expected.len() + 1) + .map(|entry| entry.map(|entry| PathBuf::from(entry.file_name()))) + .collect::, _>>(); + if actual.as_ref().ok() != Some(&expected) { + return Ok(None); + } + let Some((_, config)) = profile + .configurations + .iter() + .find(|(name, _)| name == configuration) + else { + return Ok(None); + }; + for pin in std::iter::once(config).chain(&profile.files) { + check_cancelled()?; + if !matches_file(&server.home, pin) { + return Ok(None); + } + } + Ok(Some(server)) +} + +/// Validates the exact read-only JDT LS files used by the packaged extensions. +pub fn inspect_server( + home: &Path, + os: &str, + arch: &str, + check_cancelled: &dyn Fn() -> Result<(), FunctionError>, +) -> Result, FunctionError> { + inspect_server_with(home, os, arch, &ServerProfile::pinned()?, check_cancelled) +} + +fn resolve_with( + params: &Value, + environment: &SearchEnvironment, + profile: &ServerProfile, + check_cancelled: &dyn Fn() -> Result<(), FunctionError>, +) -> Result { + check_cancelled()?; + let os = params["platform"]["os"].as_str().ok_or_else(invalid)?; + let arch = params["platform"]["arch"].as_str().ok_or_else(invalid)?; + if !["linux", "macos", "windows"].contains(&os) || !["x86_64", "arm64"].contains(&arch) { + return Err(invalid().into()); + } + let declarations = params["dependencies"].as_array().ok_or_else(invalid)?; + let mut declared = BTreeSet::new(); + for dependency in declarations { + let id = dependency["id"].as_str().ok_or_else(invalid)?; + let expected = match id { + JDK_ID => JDK_VERSION, + JDTLS_ID => &profile.version, + _ => return Err(invalid().into()), + }; + if !declared.insert(id) || dependency["version"].as_str() != Some(expected) { + return Err(invalid().into()); + } + } + if declared != BTreeSet::from([JDK_ID, JDTLS_ID]) { + return Err(invalid().into()); + } + + let mut runtimes = Vec::new(); + let mut missing = Vec::new(); + // The host has already applied explicit tool selection and probed it. + // It returns a terminal error for a broken explicit selection instead + // of asking this hook to silently replace that selection. + let tool = ¶ms["tools"][SERVER_RUNTIME_TOOL]; + let selected = absolute(tool.get("home")) + .filter(|_| tool["version"].as_str().is_some_and(java_25)) + .and_then(|home| inspect_jdk(&home, os, arch)); + let explicit_tool = tool["provider"] == "host:default" || tool["layer"] == "pinned"; + if explicit_tool && selected.is_none() { + return Err(PluginError::new( + JDK_INVALID, + "The selected JDK for JDT LS must be a complete Java 25 JDK for this platform. \ +Choose a valid JDK or clear its toolchain override to use the managed runtime.", + ) + .into()); + } + let jdk = if explicit_tool { + selected + } else { + // A managed installation remains stable when automatic discovery + // later finds a different JDK. Only an explicit user choice outranks it. + absolute(params["candidates"].get(JDK_ID)) + .and_then(|home| inspect_jdk(&home, os, arch)) + .or(selected) + }; + match jdk { + Some((home, version)) => runtimes.push(json!({"id":JDK_ID,"home":home,"version":version})), + None => missing.push(JDK_ID), + } + + let configured = match params["settings"].get(SERVER_HOME_SETTING) { + None | Some(Value::Null) => None, + Some(Value::String(text)) if text.is_empty() => None, + Some(value) => Some(absolute(Some(value)).ok_or_else(invalid)?), + }; + let server = if let Some(home) = configured { + Some( + inspect_server_with(&home, os, arch, profile, check_cancelled)? + .ok_or_else(incompatible_server)?, + ) + } else { + // A verified cache keeps subsequent starts independent of changes + // to another editor or package manager's installation. + let candidates = absolute(params["candidates"].get(JDTLS_ID)) + .into_iter() + .chain( + jdtls::candidates(environment, os) + .into_iter() + .take(MAX_DISCOVERED_SERVERS), + ); + let mut found = None; + let mut seen = BTreeSet::new(); + for home in candidates { + check_cancelled()?; + if !seen.insert(home.clone()) { + continue; + } + if let Some(server) = inspect_server_with(&home, os, arch, profile, check_cancelled)? { + found = Some(server); + break; + } + } + found + }; + match server { + Some(server) => runtimes.push(json!({ + "id":JDTLS_ID,"home":server.home,"version":profile.version + })), + None => missing.push(JDTLS_ID), + } + check_cancelled()?; + Ok(json!({"runtimes":runtimes,"missing":missing})) +} + +/// SDK entry point. Expected absence is a successful plan with `missing` IDs; +/// invalid explicit configuration is an SDK-reported error. Cancellation is +/// checked between each bounded file read and never becomes a failure log. +pub fn resolve_runtimes_function(params: Value, context: &Context) -> Result { + localize_result( + (|| { + resolve_with( + ¶ms, + &SearchEnvironment::current(), + &ServerProfile::pinned()?, + &|| context.check_cancelled().map_err(Into::into), + ) + })(), + params["language"].as_str().unwrap_or_default(), + ) +} + +fn localize_result( + result: Result, + language: &str, +) -> Result { + if !language.to_ascii_lowercase().starts_with("zh") { + return result; + } + result.map_err(|failure| { + let FunctionError::Plugin(error) = &failure else { + return failure; + }; + let message = match error.code() { + INVALID_PARAMS => "Java 支持收到的运行环境准备参数无效。", + SERVER_INCOMPATIBLE => "所选语言服务器与已验证的 JDT LS 1.61.0 文件不一致。请选择该版本,或清空“语言服务器目录”,由 Lithe 自动准备。", + JDK_INVALID => "JDT LS 所选运行环境必须是适合当前平台的完整 JDK 25。请选择有效的 JDK,或清空该工具链的覆盖设置以使用自动管理的运行环境。", + NOT_PREPARED => "Java 语言服务环境尚未就绪,请重试 Java 支持的运行环境准备。", + PROFILE_INVALID => "Java 支持无法读取运行环境要求,请重新安装插件。", + _ => return failure, + }; + PluginError::new(error.code(), message).into() + }) +} + +#[cfg(test)] +mod tests { + use super::*; + use std::sync::atomic::{AtomicU64, Ordering}; + + #[test] + fn runtime_errors_follow_ui_language_and_preserve_categories() { + for code in ERROR_CODES { + for language in ["zh-CN", "zh-Hans", "ZH-tw"] { + let result = localize_result( + Err(PluginError::new(*code, "English recovery guidance.").into()), + language, + ); + let Err(FunctionError::Plugin(error)) = result else { + panic!("expected a localized plugin error"); + }; + assert_eq!(error.code(), *code); + assert!(!error.message().is_ascii()); + } + for language in ["", "en", "en-US", "de"] { + let result = localize_result( + Err(PluginError::new(*code, "English recovery guidance.").into()), + language, + ); + let Err(FunctionError::Plugin(error)) = result else { + panic!("expected an English plugin error"); + }; + assert_eq!(error.code(), *code); + assert_eq!(error.message(), "English recovery guidance."); + } + } + assert!(matches!( + localize_result(Err(FunctionError::Cancelled), "zh-Hans"), + Err(FunctionError::Cancelled) + )); + } + + struct Fixture(PathBuf); + + impl Fixture { + fn new() -> Self { + static NEXT: AtomicU64 = AtomicU64::new(0); + let root = std::env::temp_dir().join(format!( + "lithe-managed-java-{}-{}", + std::process::id(), + NEXT.fetch_add(1, Ordering::SeqCst) + )); + fs::create_dir_all(&root).unwrap(); + Self(dunce::canonicalize(root).unwrap()) + } + + fn jdk(&self, name: &str, os: &str, arch: &str, version: &str) -> PathBuf { + let home = self.0.join(name); + for directory in ["bin", "lib", "jmods"] { + fs::create_dir_all(home.join(directory)).unwrap(); + } + let os_name = match os { + "macos" => "Darwin", + "windows" => "Windows", + _ => "Linux", + }; + fs::write( + home.join("release"), + format!("JAVA_VERSION=\"{version}\"\nOS_ARCH=\"{arch}\"\nOS_NAME=\"{os_name}\"\n"), + ) + .unwrap(); + let mut bytes = vec![0u8; 8192]; + match os { + "linux" => { + bytes[..6].copy_from_slice(&[0x7f, b'E', b'L', b'F', 2, 1]); + let machine: u16 = if arch == "arm64" { 183 } else { 62 }; + bytes[18..20].copy_from_slice(&machine.to_le_bytes()); + } + "macos" => { + bytes[..4].copy_from_slice(&[0xcf, 0xfa, 0xed, 0xfe]); + let cpu: u32 = if arch == "arm64" { + 0x0100000c + } else { + 0x01000007 + }; + bytes[4..8].copy_from_slice(&cpu.to_le_bytes()); + } + "windows" => { + bytes[..2].copy_from_slice(b"MZ"); + bytes[60..64].copy_from_slice(&128u32.to_le_bytes()); + bytes[128..132].copy_from_slice(b"PE\0\0"); + let machine: u16 = if arch == "arm64" { 0xaa64 } else { 0x8664 }; + bytes[132..134].copy_from_slice(&machine.to_le_bytes()); + } + _ => unreachable!(), + } + for name in ["java", "javac"] { + let suffix = if os == "windows" { ".exe" } else { "" }; + let path = home.join(format!("bin/{name}{suffix}")); + fs::write(&path, &bytes).unwrap(); + #[cfg(unix)] + { + use std::os::unix::fs::PermissionsExt; + fs::set_permissions(path, fs::Permissions::from_mode(0o755)).unwrap(); + } + } + fs::write(home.join("lib/modules"), b"module image").unwrap(); + fs::write(home.join("jmods/java.base.jmod"), b"base module").unwrap(); + home + } + + fn server(&self, name: &str) -> (PathBuf, ServerProfile) { + let home = self.0.join(name); + fs::create_dir_all(home.join("plugins")).unwrap(); + fs::create_dir_all(home.join("config_linux")).unwrap(); + let paths = [ + "plugins/org.eclipse.equinox.launcher_1.8.0.fixture.jar", + "plugins/org.eclipse.jdt.ls.core_1.61.0.fixture.jar", + "config_linux/config.ini", + ]; + let mut files = Vec::new(); + for path in paths { + let content = format!("verified fixture {path}"); + fs::write(home.join(path), &content).unwrap(); + files.push(PinnedFile { + path: PathBuf::from(path), + size: content.len() as u64, + sha256: format!("{:x}", Sha256::digest(content.as_bytes())), + }); + } + let config = files.pop().unwrap(); + ( + home, + ServerProfile { + version: "1.61.0".into(), + files, + configurations: vec![("config_linux".into(), config)], + }, + ) + } + + fn params(&self) -> Value { + json!({ + "platform":{"os":"linux","arch":"x86_64"}, + "dependencies":[{"id":"jdk","version":JDK_VERSION},{"id":"jdtls","version":"1.61.0"}], + "candidates":{},"tools":{},"settings":{} + }) + } + } + + impl Drop for Fixture { + fn drop(&mut self) { + let _ = fs::remove_dir_all(&self.0); + } + } + + #[test] + fn requests_only_the_missing_dependency_and_never_changes_the_project_jdk() { + let fixture = Fixture::new(); + let (server, profile) = fixture.server("jdtls"); + let jdk = fixture.jdk("jdk", "linux", "x86_64", "25.0.1"); + let environment = SearchEnvironment::default(); + for (has_jdk, has_server, expected) in [ + (false, false, vec![JDK_ID, JDTLS_ID]), + (true, false, vec![JDTLS_ID]), + (false, true, vec![JDK_ID]), + (true, true, vec![]), + ] { + let mut params = fixture.params(); + params["tools"]["java"] = json!({"home":"/project/jdk8","version":"8.0.392"}); + if has_jdk { + params["candidates"][JDK_ID] = json!(jdk); + } + if has_server { + params["candidates"][JDTLS_ID] = json!(server); + } + let before = params.clone(); + let result = resolve_with(¶ms, &environment, &profile, &|| Ok(())).unwrap(); + assert_eq!(result["missing"], json!(expected)); + assert_eq!( + result["runtimes"].as_array().unwrap().len(), + 2 - expected.len() + ); + assert_eq!(params, before, "runtime planning is read-only"); + assert!(result.get("tools").is_none(), "no project JDK override"); + } + } + + #[test] + fn reuses_the_host_selected_jdk_and_external_verified_server_without_downloads() { + let fixture = Fixture::new(); + let (server, profile) = fixture.server("external-server"); + let selected = fixture.jdk("selected-jdk", "linux", "x86_64", "25.0.4"); + let cached = fixture.jdk("cached-jdk", "linux", "x86_64", JDK_VERSION); + let mut params = fixture.params(); + params["tools"][SERVER_RUNTIME_TOOL] = json!({ + "home":selected,"version":"25.0.4","provider":"host:default","layer":"global" + }); + params["candidates"][JDK_ID] = json!(cached); + let environment = SearchEnvironment { + server_home: Some(server.clone()), + ..SearchEnvironment::default() + }; + let result = resolve_with(¶ms, &environment, &profile, &|| Ok(())).unwrap(); + assert_eq!(result["missing"], json!([])); + assert_eq!(result["runtimes"][0]["home"], json!(selected)); + assert_eq!(result["runtimes"][0]["version"], "25.0.4"); + assert_eq!(result["runtimes"][1]["home"], json!(server)); + } + + #[test] + fn incomplete_or_mixed_server_is_not_reused_and_an_explicit_one_is_an_error() { + let fixture = Fixture::new(); + let (server, profile) = fixture.server("server"); + let core = server.join("plugins/org.eclipse.jdt.ls.core_1.61.0.fixture.jar"); + let mut content = fs::read(&core).unwrap(); + content[0] ^= 1; // Same name and size, so existence/version checks cannot catch it. + fs::write(&core, content).unwrap(); + let mut params = fixture.params(); + params["candidates"][JDTLS_ID] = json!(server); + let environment = SearchEnvironment::default(); + let result = resolve_with(¶ms, &environment, &profile, &|| Ok(())).unwrap(); + assert_eq!(result["missing"], json!([JDK_ID, JDTLS_ID])); + params["settings"][SERVER_HOME_SETTING] = json!(server); + match resolve_with(¶ms, &environment, &profile, &|| Ok(())).unwrap_err() { + FunctionError::Plugin(error) => assert_eq!(error.code(), SERVER_INCOMPATIBLE), + error => panic!("unexpected error {error:?}"), + } + fs::remove_file(core).unwrap(); + assert!( + inspect_server_with(&server, "linux", "x86_64", &profile, &|| Ok(())) + .unwrap() + .is_none() + ); + } + + #[test] + fn full_jdk_checks_are_platform_specific_and_reject_jre_wrong_arch_and_partial_files() { + let fixture = Fixture::new(); + for os in ["linux", "macos", "windows"] { + for arch in ["x86_64", "arm64"] { + let home = fixture.jdk(&format!("{os}-{arch}"), os, arch, "25.0.1"); + assert!(inspect_jdk(&home, os, arch).is_some(), "{os}/{arch}"); + let other_arch = if arch == "arm64" { "x86_64" } else { "arm64" }; + assert!(inspect_jdk(&home, os, other_arch).is_none()); + let suffix = if os == "windows" { ".exe" } else { "" }; + fs::write(home.join(format!("bin/java{suffix}")), b"").unwrap(); + assert!(inspect_jdk(&home, os, arch).is_none()); + } + } + for version in ["21.0.9", "24.0.2", "26.0.1", "25-ea"] { + let home = fixture.jdk(version, "linux", "x86_64", version); + assert!(inspect_jdk(&home, "linux", "x86_64").is_none(), "{version}"); + } + let jre = fixture.jdk("jre", "linux", "x86_64", "25.0.1"); + fs::remove_file(jre.join("bin/javac")).unwrap(); + assert!(inspect_jdk(&jre, "linux", "x86_64").is_none()); + } + + #[test] + fn native_launcher_header_must_match_release_metadata_and_executable_permission() { + let fixture = Fixture::new(); + let home = fixture.jdk("jdk", "linux", "x86_64", "25"); + let java = home.join("bin/java"); + let mut bytes = fs::read(&java).unwrap(); + bytes[18..20].copy_from_slice(&183u16.to_le_bytes()); + fs::write(&java, &bytes).unwrap(); + assert!(inspect_jdk(&home, "linux", "x86_64").is_none()); + bytes[18..20].copy_from_slice(&62u16.to_le_bytes()); + fs::write(&java, &bytes).unwrap(); + #[cfg(unix)] + { + use std::os::unix::fs::PermissionsExt; + fs::set_permissions(java, fs::Permissions::from_mode(0o644)).unwrap(); + assert!(inspect_jdk(&home, "linux", "x86_64").is_none()); + } + } + + #[test] + fn an_invalid_explicit_service_jdk_does_not_fall_back_to_the_cache() { + let fixture = Fixture::new(); + let (_, profile) = fixture.server("server"); + let selected = fixture.jdk("selected-jre", "linux", "x86_64", "25.0.1"); + fs::remove_file(selected.join("bin/javac")).unwrap(); + let cached = fixture.jdk("managed-jdk", "linux", "x86_64", JDK_VERSION); + let mut params = fixture.params(); + params["tools"][SERVER_RUNTIME_TOOL] = json!({ + "home":selected,"version":"25.0.1","provider":"host:default","layer":"global" + }); + params["candidates"][JDK_ID] = json!(cached); + match resolve_with(¶ms, &SearchEnvironment::default(), &profile, &|| Ok(())) + .unwrap_err() + { + FunctionError::Plugin(error) => assert_eq!(error.code(), JDK_INVALID), + error => panic!("unexpected error {error:?}"), + } + } + + #[test] + fn verified_cache_precedes_an_automatically_discovered_jdk() { + let fixture = Fixture::new(); + let (_, profile) = fixture.server("server"); + let discovered = fixture.jdk("automatic-jdk", "linux", "x86_64", "25.0.4"); + let cached = fixture.jdk("managed-jdk", "linux", "x86_64", JDK_VERSION); + let mut params = fixture.params(); + params["tools"][SERVER_RUNTIME_TOOL] = json!({ + "home":discovered,"version":"25.0.4","provider":"host:discovered","layer":"automatic" + }); + params["candidates"][JDK_ID] = json!(cached); + let result = + resolve_with(¶ms, &SearchEnvironment::default(), &profile, &|| Ok(())).unwrap(); + assert_eq!(result["runtimes"][0]["home"], json!(cached)); + assert_eq!(result["runtimes"][0]["version"], JDK_VERSION); + } + + #[test] + fn an_extra_bundle_is_not_a_verified_distribution() { + let fixture = Fixture::new(); + let (home, profile) = fixture.server("server"); + fs::write(home.join("plugins/another.bundle_2.0.jar"), b"extra bundle").unwrap(); + assert!( + inspect_server_with(&home, "linux", "x86_64", &profile, &|| Ok(())) + .unwrap() + .is_none() + ); + } + + #[test] + fn cancellation_interrupts_qualification_without_a_partial_result() { + use std::cell::Cell; + let fixture = Fixture::new(); + let (server, profile) = fixture.server("server"); + let mut params = fixture.params(); + params["candidates"][JDTLS_ID] = json!(server); + let checks = Cell::new(0); + let result = resolve_with(¶ms, &SearchEnvironment::default(), &profile, &|| { + checks.set(checks.get() + 1); + if checks.get() == 4 { + Err(FunctionError::Cancelled) + } else { + Ok(()) + } + }); + assert!(matches!(result, Err(FunctionError::Cancelled))); + assert_eq!(checks.get(), 4); + } + + #[test] + fn the_compiled_profile_binds_all_platform_templates_to_the_pinned_archive() { + let profile = ServerProfile::pinned().unwrap(); + assert_eq!(profile.version, "1.61.0"); + assert!(profile.files.len() > 100); + for (os, arch) in [ + ("linux", "x86_64"), + ("linux", "arm64"), + ("macos", "x86_64"), + ("macos", "arm64"), + ("windows", "x86_64"), + ("windows", "arm64"), + ] { + let name = jdtls::configuration_name(os, arch).unwrap(); + assert!(profile.configurations.iter().any(|(key, _)| key == name)); + } + } +} diff --git a/backend/tests/repository_pins.rs b/backend/tests/repository_pins.rs index cf2aa6e..a8d9e18 100644 --- a/backend/tests/repository_pins.rs +++ b/backend/tests/repository_pins.rs @@ -11,6 +11,7 @@ use lithe_java_backend::launch::{ EXTENSIONS_DIRECTORY, LAUNCH_FUNCTION_ID, MINIMUM_SERVER_JAVA_VERSION, PACKAGE_LAYOUT, SERVER_RUNTIME_TOOL, }; +use lithe_java_backend::managed_runtimes::{JDK_VERSION, RESOLVE_FUNCTION_ID}; use serde_json::Value; use std::fs; use std::path::{Path, PathBuf}; @@ -192,10 +193,7 @@ fn package_scripts_name_every_path_the_backend_resolves() { } #[test] -fn the_users_jdt_ls_runs_on_the_declared_runtime_tool() { - // JDT LS and its JDK come from the user's machine: the package ships - // neither, the backend answers the runtime tool the manifest defines, and - // the user can choose the JDT LS folder in a setting the backend reads. +fn the_language_service_jdk_is_separate_from_the_project_jdk() { let manifest = read_json(&format!("{PLUGIN_ID}/plugin.json")); let tools: Vec<&str> = manifest["requiresTools"] .as_array() @@ -213,56 +211,33 @@ fn the_users_jdt_ls_runs_on_the_declared_runtime_tool() { .iter() .find(|definition| definition["id"] == "java") .unwrap(); - // The runtime finds JDKs where the project JDK is found, plus the JREs - // bundled inside VS Code and Cursor `redhat.java` extensions. + // Discovery reuses full JDK installations, not editor-specific JREs. let java_discovery = java["discovery"].as_array().unwrap(); let runtime_discovery = runtime["discovery"].as_array().unwrap(); assert!( runtime_discovery.len() <= 16, "Core allows at most 16 discovery entries per tool" ); - assert_eq!(&runtime_discovery[..java_discovery.len()], java_discovery); - let extra_patterns: Vec<&str> = runtime_discovery[java_discovery.len()..] - .iter() - .map(|entry| text(entry, "pattern")) - .collect(); - assert_eq!( - extra_patterns, - [ - ".vscode/extensions/redhat.java-*/jre/*", - ".cursor/extensions/redhat.java-*/jre/*", - ] - ); + assert_eq!(runtime_discovery, java_discovery); assert_eq!(runtime["executableLayouts"], java["executableLayouts"]); let runtime_pattern = text(&runtime["version"], "pattern"); + let pattern = regex::Regex::new(runtime_pattern).unwrap(); for rejected in [ r#"java version "1.8.0_301""#, r#"openjdk version "11.0.20""#, r#"openjdk version "17.0.10""#, r#"openjdk version "20.0.2""#, + r#"openjdk version "21.0.9""#, + r#"openjdk version "24.0.2""#, + r#"openjdk version "26.0.1""#, + r#"openjdk version "250.0.1""#, ] { - assert!( - !rejected.contains("version \"21") && { - // `jdtls-runtime` only matches Java 21+, so an older `java` on - // PATH cannot shadow a discovered JDK 21+. - let digits = rejected.split('"').nth(1).unwrap(); - let major: u64 = digits - .strip_prefix("1.") - .unwrap_or(digits) - .split('.') - .next() - .unwrap() - .parse() - .unwrap(); - major < MINIMUM_SERVER_JAVA_VERSION - }, - "{rejected}" - ); + assert!(!pattern.is_match(rejected), "{rejected}"); + } + for version in ["25", "25.0.1", "25.0.5.0.2"] { + let output = format!("openjdk version \"{version}\" LTS"); + assert_eq!(&pattern.captures(&output).unwrap()[1], version); } - assert!( - runtime_pattern.contains("2[1-9]") && !runtime_pattern.contains("(?:1\\.)?"), - "jdtls-runtime version.pattern must require Java 21+: {runtime_pattern}" - ); // It exports nothing, so JDT LS keeps the environment the host gives it. assert!(runtime.get("exports").is_none()); assert!(runtime.get("pathPrepend").is_none()); @@ -277,15 +252,74 @@ fn the_users_jdt_ls_runs_on_the_declared_runtime_tool() { assert_eq!(text(setting, "default"), ""); let pins = read_json("third_party/jdtls/manifest.json"); - assert_eq!( - pins["minimumJavaVersion"].as_u64(), - Some(MINIMUM_SERVER_JAVA_VERSION), - "the tested JDT LS and the backend must agree on its oldest Java" - ); - assert!( - !repository_root().join("third_party/jdk").exists(), - "the package ships no JDK" - ); + assert!(pins["minimumJavaVersion"].as_u64().unwrap() <= MINIMUM_SERVER_JAVA_VERSION); +} + +#[test] +fn managed_dependencies_pin_all_six_platforms_and_bind_only_the_service_tool() { + let manifest = read_json(&format!("{PLUGIN_ID}/plugin.json")); + assert_eq!(manifest["requires"]["managedRuntimes"], 0); + assert!(manifest["permissions"] + .as_array() + .unwrap() + .contains(&Value::String("runtimes.install".into()))); + let managed = &manifest["managedRuntimes"]; + assert_eq!(managed["resolve"]["function"], RESOLVE_FUNCTION_ID); + assert!(managed["resolve"]["timeoutMilliseconds"].as_u64().unwrap() > 0); + let dependencies = managed["dependencies"].as_array().unwrap(); + assert_eq!(dependencies.len(), 2); + let pins = read_json("third_party/jdtls/manifest.json"); + for dependency in dependencies { + let artifacts = dependency["artifacts"].as_array().unwrap(); + let mut platforms = std::collections::BTreeSet::new(); + for artifact in artifacts { + assert!(platforms.insert((text(artifact, "os"), text(artifact, "arch")))); + assert!(text(artifact, "url").starts_with("https://")); + assert_sha256( + artifact["sha256"].as_str().expect("archive checksum"), + "managed runtime archive", + ); + if dependency["id"] == "jdk" { + assert_eq!(dependency["tool"], SERVER_RUNTIME_TOOL); + assert_eq!(dependency["version"], JDK_VERSION); + assert_eq!(artifact["stripPrefix"], "jdk-25.0.5.0.2+1"); + let windows = artifact["os"] == "windows"; + assert_eq!(artifact["archive"], if windows { "zip" } else { "tar.gz" }); + assert_eq!( + artifact["executable"], + if windows { "bin/java.exe" } else { "bin/java" } + ); + assert_eq!( + artifact["home"], + if artifact["os"] == "macos" { + "Contents/Home" + } else { + "" + } + ); + } else { + assert_eq!(dependency["id"], "jdtls"); + assert!(dependency.get("tool").is_none()); + assert_eq!(dependency["version"], pins["version"]); + assert_eq!(artifact["url"], pins["archiveURL"]); + assert_eq!(artifact["sha256"], pins["archiveSHA256"]); + } + } + assert_eq!( + platforms, + std::collections::BTreeSet::from([ + ("linux", "x86_64"), + ("linux", "arm64"), + ("macos", "x86_64"), + ("macos", "arm64"), + ("windows", "x86_64"), + ("windows", "arm64"), + ]) + ); + } + let profile = read_json("third_party/jdtls/runtime-files.json"); + assert_eq!(profile["version"], pins["version"]); + assert_eq!(profile["archiveSHA256"], pins["archiveSHA256"]); } #[test] diff --git a/contract.lock.json b/contract.lock.json new file mode 100644 index 0000000..8ad2318 --- /dev/null +++ b/contract.lock.json @@ -0,0 +1,18 @@ +{ + "repository": "https://github.com/Lithe-IDEA/Lithe-core-rust", + "commit": "7f1fc4becd0b4b415aa463abd0ea5e2810b3e964", + "schemas": [ + { + "path": "plugin-manifest.schema.json", + "sha256": "b28a4874018cd89d49d7feda31c158a10ac1d7050891bc832be0bc5b649b5beb" + }, + { + "path": "native-ui.schema.json", + "sha256": "e85bafc4b52f82bada93ef1d850e91372597411a8587829e6b047703cde3ad81" + }, + { + "path": "plugin-l10n.schema.json", + "sha256": "71fb928257139ee970be3c9d41d6e5cde147a5f6b786a460f3279b6ebd8d52ed" + } + ] +} diff --git a/docs/feature-matrix.md b/docs/feature-matrix.md index 5426a04..baea152 100644 --- a/docs/feature-matrix.md +++ b/docs/feature-matrix.md @@ -1,14 +1,15 @@ # 功能验证矩阵 -## 语言服务器来源(3.0.0) +## 自动准备语言服务环境(本次改动) | 能力 | macOS | Windows | Linux | 证据 | | --- | --- | --- | --- | --- | -| 使用用户安装的 JDT LS(设置目录、`JDTLS_HOME`、`PATH` 上的 `jdtls`、Homebrew、mason.nvim、Scoop、VS Code Java 扩展) | implemented / verified | implemented / pending | implemented / pending | `backend/src/jdtls.rs` 单元测试;macOS arm64 本机用 Homebrew JDT LS 1.60.0 和固定的 1.61.0 跑 `scripts/compiler/test-live.mjs`(普通与 Eclipse 工程),核对插件包与 JDT LS 安装文件不变 | -| 用 `jdtls-runtime` 工具(仅匹配 JDK 21+,含 VS Code / Cursor `redhat.java` 自带 JRE)运行 JDT LS,低于目标 JDT LS bundle 要求的最低 Java 版本(如 21 或 25)时报错 | implemented / verified | implemented / pending | implemented / pending | `backend/src/jdtls.rs`、`backend/src/launch.rs`、`backend/tests/repository_pins.rs` 单元测试;本机 JDK 21、25、26 均已验证,JDK 26 运行 JDT LS 时需宿主传入项目 JDK | -| 插件包不含 JDT LS 和 JDK | implemented / verified | implemented / pending | implemented / pending | `scripts/verify-package.sh`、`scripts/package/build-linux.mjs`;macOS arm64 包 11.3 MiB | +| 完整 JDK 25 与固定 JDT LS 分别声明,已有依赖复用,只下载缺失部分 | implemented / pending | implemented / pending | x64 verified;ARM64 pending | `managed_runtimes` 单元测试覆盖四种存在组合;真实宿主安装结果见 [运行环境说明](managed-runtimes.md) | +| JDT LS 精确 114 文件 + 当前平台模板校验,拒绝混装/残缺;完整 JDK 的版本、OS、CPU、java/javac 执行文件检查 | implemented / pending | implemented / pending | x64 verified;ARM64 pending | 六平台文件布局与 ELF / Mach-O / PE 头单测;Linux 用官方归档及真实 SDK hook | +| 服务 JDK 25 独立于项目 JDK;显式选择优先,再复用受管缓存,最后自动发现 | implemented / pending | implemented / pending | x64 verified;ARM64 pending | `backend/src/managed_runtimes.rs`、`repository_pins.rs`;真实 launch 只绑定 `jdtls-runtime` | +| 插件 ZIP 无 JDT LS/JDK;批准的 runtimes map 启动真实 JDT,包/运行环境保持只读 | implemented / pending | implemented / pending | x64 verified;ARM64 pending | `scripts/package/smoke-linux.mjs` 的完整快照与 initialize/shutdown;[Linux 验证](linux-packaging.md) | -2026-11-16:Windows 与 Linux 的原生结果以 CI 和后续实机验证为准,本机结果不能推断。 +2026-11-18:官方完整 JDK 六平台 URL / SHA-256 与归档根目录已核对;实际机器运行仅覆盖 Linux x64,不能用文件头单测或下载可用性宣称其他平台原生通过。Windows ARM64 的运行环境声明不代表已新增 ARM64 宿主或插件发布包。此前 3.0.0 的 macOS 外部 JDT LS 1.60.0 / JDK 21 验证属于旧行为;当前兼容性锁只接收 JDT LS 1.61.0 + 完整 JDK 25。 ## Linux 安装包 diff --git a/docs/linux-packaging.md b/docs/linux-packaging.md index db78da0..73bc1fa 100644 --- a/docs/linux-packaging.md +++ b/docs/linux-packaging.md @@ -1,13 +1,17 @@ # Linux 构建与验证 -`node scripts/package/build-linux.mjs arm64|x64` 在对应 Linux runner 上编译 Rust 后端,校验其 ELF 架构,再从固定 SHA-256 的 Lombok、Java Debug 和 Java Test 输入组装包。包里不含 JDT LS 和 JDK:插件运行用户自己安装的 JDT LS 和 JDK 21+,ARM64 读取安装里的 `config_linux_arm`,x64 读取 `config_linux`。插件 ZIP 不含链接。归档解压后再次检查清单、后端架构与执行权限,并确认包里没有 JDT LS 或 JDK。 +`node scripts/package/build-linux.mjs arm64|x64` 在对应 Linux runner 上编译 Rust 后端,校验 ELF 架构,并从固定 SHA-256 的 Lombok、Java Debug 和 Java Test 输入组装包。插件 ZIP 不含 JDT LS、JDK 或符号链接。运行环境的固定来源和校验和写入清单,由宿主在首次安装或修复时独立准备;ARM64 读取 `config_linux_arm`,x64 读取 `config_linux`。 -`node scripts/package/smoke-linux.mjs ` 在原生 runner 上运行解压后的后端握手与 `java.resolveLaunch`,把 `scripts/prepare-jdtls.sh` 准备的 JDT LS 1.61.0 当作用户的安装(CI 用 `actions/setup-java` 提供 JDK 21),执行 initialize/shutdown,并对比整个安装目录和 JDT LS 目录的文件内容与权限。状态目录和 Equinox 配置副本在临时用户目录;结束时清理进程组和目录。 +`node scripts/package/smoke-linux.mjs ` 在原生 runner 上运行解压后的 SDK 后端,用 `scripts/prepare-jdtls.sh` 准备的 JDT LS 1.61.0 和完整 JDK 25 调用两次 `java.resolveRuntimes`,检查路径复用,再把批准的 `runtimes` map 交给 `java.resolveLaunch`。真实 JDT LS 执行 initialize/shutdown;完整插件、JDT LS 和 JDK 的文件、链接目标与权限快照必须不变。状态、Equinox 配置副本和索引位于测试临时用户目录;结束时清理进程组与目录。 -Linux 产物面向 GNU/glibc 环境,原生 CI 使用 Ubuntu 24.04;本包不面向 musl/Alpine。 +既有 CI 的 JDK 21 可继续用于编译扩展。测试输入没有显式指定服务 Java、且 runner 没有 JDK 25 时,`prepare-test-jdk.mjs` 按同一清单 pin 在 `.artifacts/managed-jdk` 准备完整 JDK 25;这仅是构建/测试支持,不参与生产安装。配置 `LITHE_TEST_JDTLS_HOME`、`LITHE_TEST_JDTLS_JAVA` 可指定已准备的测试输入;显式服务 Java 必须为 25。项目扩展仍保留原有字节码基线,不因此修改项目 JDK。 + +宿主实际安装/解包验证由本仓库持有的 `scripts/package/test-host-managed.mjs` 在配套 host 检出上运行 Go overlay,调用真实 Core、SDK 后端与 `pluginservice.EnsureRuntimes`。输入是 SHA-256 已验证的官方完整归档;测试 HTTP transport 提供这些字节,不伪造解压结果,也不依赖每次联网。覆盖缓存准备、重复启动/插件更新零下载、只绑定服务工具、损坏 JDK 从已验证归档恢复。它需要不存在外部兼容运行环境的隔离 Linux x64 runner,具体命令见 [managed-runtimes.md](managed-runtimes.md)。 + +Linux 包面向 GNU/glibc 环境;原生 CI 使用 Ubuntu 24.04,不面向 musl/Alpine。原生 ARM64 和 x64 CI 的新流程必须各自在对应 runner 通过;本机 x64 结果不能替代 ARM64 验收。 ## 资源与验证边界 -所有下载、解压、编译与归档都属于本插件仓库的构建阶段。`dist/` 为输出包;`.artifacts/`、`.cache/`、`target/` 或工具自身缓存为本地构建状态,不跨工作树共享可变状态。校验过的下载以固定来源与摘要识别,提取结果不作为可信下载源。运行时只读取已安装插件,缓存、日志、索引和工作区状态归用户可写目录。Linux 不使用 macOS 代码签名或 Sparkle;本次不改变 macOS 包签名与更新基线。 +构建输出位于 `dist/`,构建下载和测试状态位于 `.artifacts/`、`.cache/`、`target/` 或工具自身缓存。用户运行环境位于宿主的插件独立 `state/runtimes`,不写进插件安装版本目录。该缓存与插件更新分别管理;首次准备后,正常启动不重新下载同一 pin。日志、索引和 Equinox 可写配置仍使用宿主状态目录。 -原生 ARM64 和 x64 验证由 `.github/workflows/ci.yml` 执行;本机的交叉编译与归档检查不能替代原生运行结果。只有目标平台 CI 成功后才能宣称该平台通过。发布新版本后,使用实际 Release 附件的 SHA-256 更新 Store,保留所有旧版本与既有平台。 +Linux 不使用 macOS 代码签名或 Sparkle。本次不改变既有 macOS 签名、Store 发布或更新基线;未发布新版本、Release 附件或 Store 条目。构建和自动化通过不等于原生窗口的全部交互验收。 diff --git a/docs/managed-runtimes.md b/docs/managed-runtimes.md new file mode 100644 index 0000000..753a129 --- /dev/null +++ b/docs/managed-runtimes.md @@ -0,0 +1,88 @@ +# Java 语言服务运行环境 + +本次实现把 Java 支持的启动依赖作为两项独立运行环境管理:完整 JDK 25 负责运行服务,JDT LS 1.61.0 负责语言能力。安装先检查本机和已准备的缓存,只下载缺失部分;插件更新继续复用相同 pin 的运行环境。项目的 `java` 工具保持独立。 + +## 固定输入与来源 + +| 依赖 | 本次固定版本 | 来源与许可 | +| --- | --- | --- | +| 完整 JDK | Microsoft Build of OpenJDK 25.0.5.0.2,build +1 | [官方下载页](https://learn.microsoft.com/en-us/java/openjdk/download)、[许可说明](https://learn.microsoft.com/en-us/java/openjdk/faq)、[对应源码](https://github.com/microsoft/openjdk-jdk25u/tree/release/jdk-25.0.5.0.2_1);GPLv2 + Classpath Exception,保留各组件 notices | +| JDT LS | 1.61.0,202609031315 | [官方归档目录](https://download.eclipse.org/jdtls/milestones/1.61.0/)、[上游项目](https://github.com/eclipse-jdtls/eclipse.jdt.ls);EPL 2.0,保留各组件许可 | +| 随包扩展 | Lombok、java-debug、java-test、插件自己的 project-model bundle | 继续使用 `third_party/jdtls/manifest.json` 中的固定版本和校验和 | + +JDK 六个平台的不可变 Microsoft 下载地址与完整 SHA-256 都写在 `plugin.json`。它们由官方版本下载链接及 `.sha256sum.txt` 核实,不使用 latest URL。六个归档的顶层目录均为 `jdk-25.0.5.0.2+1`;macOS 的 home 是其下 `Contents/Home`,Linux / Windows 是顶层本身。Windows 使用 ZIP 和 `bin/java.exe`;另外两个系统使用 tar.gz 和 `bin/java`。 + +JDT LS 归档 SHA-256 为 `338e7e73d61836651ba2453919a0d34fa763eb4e7c03342092309bffb8934c64`。它同时是构建扩展、运行环境安装和文件指纹的唯一版本输入。1.61.0 核心 bundle 的上游最低运行要求是 Java 21;本插件选择 Java 25 作为完整配套环境,不把最低要求误写成 25,也不因此把项目 Java 版本提高。 + +## 选择与准备 + +`java.resolveRuntimes` 是包内 Rust 后端提供的只读函数。它不联网、不下载、不执行候选程序、不修改安装目录;宿主负责官方归档的下载、SHA-256 校验、安全解包、文件清单、并发锁和完成记录。 + +解析顺序是显式用户选择、已有受管候选、自动发现。服务 JDK 的显式选择来自宿主工具链事实;JDT LS 的显式选择来自 `languageServerHome`。显式配置无效时给出中英恢复提示,不悄悄覆盖用户选择。普通缺失会返回 `missing` 列表,是正常安装计划。 + +JDK 必须是稳定的完整 Java 25,且 release 文件的 OS/CPU 与 `java`、`javac` 的 ELF / Mach-O / PE 头一致;两个启动文件必须为非空的本机可执行文件,并具备 `lib/modules` 与 `jmods/java.base.jmod`。JRE、其他 Java 大版本、EA、错架构和明显残缺的安装会被拒绝。宿主提供的工具安装事实已经经过有界版本探测;插件不会执行可能来自不受信任目录的发现候选。 + +JDT LS 不按“目录里有 launcher”或“版本够新”放行。`third_party/jdtls/runtime-files.json` 固定所有 114 个 `plugins/` 文件与五个原始配置模板;解析要求完整插件文件集合一致、拒绝额外混装 bundle,并逐文件比对大小及 SHA-256。选择当前平台模板后再比较其摘要。其他编辑器安装中只有与这个验证基线一致的服务器可被复用。可写 Equinox 运行配置不会参与原始模板的替换。 + +| 已通过校验的本机依赖 | `missing` | 宿主准备 | +| --- | --- | --- | +| 两者都有 | 空 | 无下载 | +| 只有 JDK | `jdtls` | 只准备 JDT LS | +| 只有 JDT LS | `jdk` | 只准备完整 JDK | +| 两者都没有 | `jdk`、`jdtls` | 分别准备两个依赖 | + +外部 JDK 的检查是发行版、版本、架构和完整布局资格检查,并非对任意厂商 JDK 的逐文件白名单。已管理的安装还接受宿主的归档摘要和文件清单校验。安装/更新前进行完整文件哈希核验;启动使用清单元数据检查与插件的兼容性校验。实际启动、项目导入和扩展运行仍可能暴露上游或外部安装的问题。 + +## 缓存和项目隔离 + +宿主把运行环境放在该插件的独立 `state/runtimes`。Core 的 cache key 绑定依赖声明、版本、平台和归档身份,不包含插件版本;每项依赖使用私有临时解包目录,完成验证后发布 `install-*` 世代和 `ready.json`。失败或取消不会把半成品当作就绪环境。校验过的归档可用于离线修复;坏缓存仅替换受影响依赖,已运行的旧世代保持可读。 + +插件版本更新但依赖不变时,不重复下载。只升级一项依赖时,另一项复用。卸载插件会随插件状态清理运行环境;旧世代目前不自动 prune,以免打断仍在运行的进程或回滚。 + +解析结果包含完整 `runtimes` / `missing` 分区。准备完成后,宿主把它转为 `java.resolveLaunch` 的映射: + +```json +{ + "runtimes": { + "jdk": {"home": "/approved/jdk-home", "version": "25.0.5.0.2"}, + "jdtls": {"home": "/approved/server-home", "version": "1.61.0"} + } +} +``` + +启动使用批准的 JDT LS 目录并再次检查指纹;JDK 只绑定 `jdtls-runtime`,不改 `java`、全局 `JAVA_HOME`、项目的 source/target/release、Maven 或 Gradle 设置。项目仍通过原有 `java` 工具和 JDT runtime 配置选择 JDK。未显式选择项目 JDK 时,JDT 的默认行为可能使用服务 JDK;旧项目应选择其实际项目 JDK。 + +JDT LS、JDK 和已安装插件在运行期只读。Equinox 配置副本、工作区索引、日志和临时文件写入宿主传入的用户状态目录。缓存齐全后的语言服务启动无需下载,但项目依赖仍可能由 Maven / Gradle 联网解析。 + +## 权限、诊断和版本门槛 + +清单增加 `requires.managedRuntimes: 0` 和 `runtimes.install`,由支持此能力的配套 Lithe / Core 执行。后端继续使用已有固定 Rust SDK,因为该 hook 采用现有函数 JSON 协议。独立的 `contract.lock.json` 固定支持该能力的 Core `7f1fc4becd0b4b415aa463abd0ea5e2810b3e964` 及 manifest/native-ui/l10n schema 摘要;已有 CI / Release 调用的 `verify-sdk-lock.sh --download` 会在隔离 Python 环境中用固定 jsonschema 4.26.0 验证,不依赖本地 Core 检出。旧宿主不具备新声明的实现,不能把新包当作已兼容发布。 + +正常缺失和成功读取不记录 ERROR / INFO。SDK 为失败记录稳定类别 `runtime.invalid_params`、`runtime.server_incompatible`、`runtime.jdk_invalid`、`runtime.not_prepared`、`runtime.profile_invalid`,不输出路径或工具输出;取消保持取消语义。宿主提供 `language` 时,`zh` 前缀采用中文,其他语言回退英文。 + +## 验证入口与边界 + +单元测试覆盖四种存在组合、项目工具不变、显式选择、缓存优先、错误 JDK 大版本/架构、JRE、空文件、非可执行文件、JDT 缺失/损坏/额外 bundle、取消、中英错误以及六个平台的文件布局与原生文件头。清单测试检查全部 pin 与平台覆盖,profile 生成器只在审查过的上游升级时重写。 + +Linux x64 的实际输入为上述 Microsoft 完整 JDK 和 JDT LS。测试包调用真实 SDK 后端,连续两次解析已准备环境,再通过批准的 map 启动真实 JDT LS;initialize/shutdown 后插件、JDT LS、JDK 的完整内容和权限快照不变。一次观测的完整 JDT 文件校验为 62.1 / 58.1 ms,属于该机器的热文件缓存观测,不是跨平台性能保证。 + +```sh +cargo test --locked --workspace +node scripts/package/jdtls-runtime-profile.mjs .artifacts/jdtls +node scripts/package/build-linux.mjs x64 +node scripts/package/smoke-linux.mjs dist/Lithe-Java-Support-4.0.2-linux-x64.zip +``` + +可用 `JAVA_HOME` 或 `LITHE_TEST_JDTLS_JAVA` 指向完整 Java 25。没有显式服务 Java、且 runner 的默认 JDK 不是 25 时,测试 helper 按同一官方 pin 在 `.artifacts` 准备完整 JDK;原有 CI 编译扩展的 JDK 21 和 workflow 均不需要修改。`scripts/compiler/test-live.mjs ` 使用同一 hook + map 流程,验证实际 JDT 导入、外部 JAR、Java 8 字节码和运行结果;项目运行 JDK 可用 `LITHE_TEST_PROJECT_JAVA_HOME` 独立指定。 + +`test-host-managed.mjs` 把 Java 仓库持有的 Go fixture 临时 overlay 到配套 host,调用真实 Core、SDK 后端、`pluginservice.EnsureRuntimes`、ArchiveDownloader 和 Manager。它只替换 HTTP transport,用已从官方核验下载的完整归档作为字节流,验证实际解包、启动/插件更新零新增传输、服务工具隔离、JDK 损坏后的离线修复。测试不修改 host 源码,不把 Java 特例放入宿主,也不把网络耗时当可靠性门槛。它要求没有可复用外部环境的隔离 Linux x64 runner。本轮真实宿主测试通过,测试本体 35.66 秒;两个输入各传输一次,后续启动、插件更新和 JDK 修复均没有额外传输。 + +```sh +LITHE_CORE_RUST_DIR=/path/to/paired-core \ +node scripts/package/test-host-managed.mjs /path/to/paired-host \ + dist/Lithe-Java-Support-4.0.2-linux-x64.zip +``` + +默认输入位于 `.artifacts/managed-jdk/microsoft-jdk-25.0.5.0.2-linux-x64.tar.gz` 和 `prepare-jdtls.sh` 的固定归档缓存;可用 `LITHE_MANAGED_TEST_JDK_ARCHIVE` / `LITHE_MANAGED_TEST_JDTLS_ARCHIVE` 覆盖,仍须通过清单摘要核验。 + +macOS、Linux ARM64、Windows x64 和 Windows ARM64 的真实运行仍待各自 runner 验证。官方下载存在、归档结构可读或跨平台文件头单测不能替代原生测试;Windows ARM64 依赖声明也不代表宿主/插件已经发布 ARM64 二进制。配置错误、旧项目模型、私有仓库认证、JSP 支持与任意 Maven/Gradle 版本兼容性不由运行环境自动准备解决。 diff --git a/io.github.lithe-idea.java-support/l10n/zh-Hans.json b/io.github.lithe-idea.java-support/l10n/zh-Hans.json index 25f057b..2db7635 100644 --- a/io.github.lithe-idea.java-support/l10n/zh-Hans.json +++ b/io.github.lithe-idea.java-support/l10n/zh-Hans.json @@ -2,7 +2,7 @@ "settings": { "languageServerHome": { "title": "语言服务器目录", - "description": "Eclipse JDT Language Server 的目录,即包含 plugins 和 config 目录的那一层。留空时自动查找:JDTLS_HOME、PATH 上的 jdtls,以及 Homebrew、mason.nvim、Scoop 或 VS Code Java 扩展安装的 JDT LS。", + "description": "可选的 Eclipse JDT Language Server 1.61.0 目录。留空时复用已验证兼容的安装,缺少时由 Lithe 自动准备固定版本的语言服务器和独立的 Java 25 运行环境;不会更改项目自己的 JDK。", "placeholder": "自动查找" }, "heapMaxMB": { diff --git a/io.github.lithe-idea.java-support/plugin.json b/io.github.lithe-idea.java-support/plugin.json index 517d3a4..b22671e 100644 --- a/io.github.lithe-idea.java-support/plugin.json +++ b/io.github.lithe-idea.java-support/plugin.json @@ -4,14 +4,143 @@ "displayName": "Java Support", "version": "4.0.2", "pluginAPIVersion": 0, - "requires": {"backend": 0, "debugAdapters": 0, "languages": 0, "languageServers": 0, "pluginFunctions": 0, "settings": 0, "projectGenerators": 0, "toolDefinitions": 0, "sourceSettings": 1}, + "requires": {"backend": 0, "debugAdapters": 0, "languages": 0, "languageServers": 0, "pluginFunctions": 0, "settings": 0, "projectGenerators": 0, "toolDefinitions": 0, "sourceSettings": 1, "managedRuntimes": 0}, + "managedRuntimes": { + "resolve": { + "function": "java.resolveRuntimes", + "timeoutMilliseconds": 30000 + }, + "dependencies": [ + { + "id": "jdk", + "version": "25.0.5.0.2", + "tool": "jdtls-runtime", + "artifacts": [ + { + "os": "linux", + "arch": "arm64", + "url": "https://download.visualstudio.microsoft.com/download/pr/14450a49-85cd-4a91-aae1-73533f29b50f/da3e0632472c574335f779d20fa96bda/microsoft-jdk-25.0.5.0.2-linux-aarch64.tar.gz", + "sha256": "c0551fe6c3ea5b3244b74a275562bff128ae96563b0e13303597ccba72d15fa5", + "archive": "tar.gz", + "stripPrefix": "jdk-25.0.5.0.2+1", + "home": "", + "executable": "bin/java" + }, + { + "os": "linux", + "arch": "x86_64", + "url": "https://download.visualstudio.microsoft.com/download/pr/14450a49-85cd-4a91-aae1-73533f29b50f/fc1ef3012ee520e0c6c9663e30c9dc34/microsoft-jdk-25.0.5.0.2-linux-x64.tar.gz", + "sha256": "173e8e4286289335b422b591c88a1f553fc44c701a876a7c8dd29037a598fc14", + "archive": "tar.gz", + "stripPrefix": "jdk-25.0.5.0.2+1", + "home": "", + "executable": "bin/java" + }, + { + "os": "macos", + "arch": "arm64", + "url": "https://download.visualstudio.microsoft.com/download/pr/14450a49-85cd-4a91-aae1-73533f29b50f/9664b951f4e9f908d29d89bb749e453d/microsoft-jdk-25.0.5.0.2-macos-aarch64.tar.gz", + "sha256": "c9cf199844411c8bafd05722d2547538300523a63ff6207a440c71b175ff7873", + "archive": "tar.gz", + "stripPrefix": "jdk-25.0.5.0.2+1", + "home": "Contents/Home", + "executable": "bin/java" + }, + { + "os": "macos", + "arch": "x86_64", + "url": "https://download.visualstudio.microsoft.com/download/pr/14450a49-85cd-4a91-aae1-73533f29b50f/146488b930fd4721e6553826415e3d50/microsoft-jdk-25.0.5.0.2-macos-x64.tar.gz", + "sha256": "e92259d25beacd96b6446edbf769f1d96beca706d486ddd34a25c9166befa05b", + "archive": "tar.gz", + "stripPrefix": "jdk-25.0.5.0.2+1", + "home": "Contents/Home", + "executable": "bin/java" + }, + { + "os": "windows", + "arch": "arm64", + "url": "https://download.visualstudio.microsoft.com/download/pr/d3500af4-89c2-41c0-9a46-fae21d52f60b/4d925698e1db1bae2554b2e89c5e2399/microsoft-jdk-25.0.5.0.2-windows-aarch64.zip", + "sha256": "f227cc459fbd65a42c1b28123d68e207eb500899c1c78238f21a038cd33688a3", + "archive": "zip", + "stripPrefix": "jdk-25.0.5.0.2+1", + "home": "", + "executable": "bin/java.exe" + }, + { + "os": "windows", + "arch": "x86_64", + "url": "https://download.visualstudio.microsoft.com/download/pr/d3500af4-89c2-41c0-9a46-fae21d52f60b/dbca35c699765b2a740ca73973a92715/microsoft-jdk-25.0.5.0.2-windows-x64.zip", + "sha256": "5da7525c8268a10a66bd76a39f4e9af24d4ebc974d42800a609852c498a68460", + "archive": "zip", + "stripPrefix": "jdk-25.0.5.0.2+1", + "home": "", + "executable": "bin/java.exe" + } + ] + }, + { + "id": "jdtls", + "version": "1.61.0", + "artifacts": [ + { + "os": "linux", + "arch": "arm64", + "url": "https://download.eclipse.org/jdtls/milestones/1.61.0/jdt-language-server-1.61.0-202609031315.tar.gz", + "sha256": "338e7e73d61836651ba2453919a0d34fa763eb4e7c03342092309bffb8934c64", + "archive": "tar.gz", + "home": "" + }, + { + "os": "linux", + "arch": "x86_64", + "url": "https://download.eclipse.org/jdtls/milestones/1.61.0/jdt-language-server-1.61.0-202609031315.tar.gz", + "sha256": "338e7e73d61836651ba2453919a0d34fa763eb4e7c03342092309bffb8934c64", + "archive": "tar.gz", + "home": "" + }, + { + "os": "macos", + "arch": "arm64", + "url": "https://download.eclipse.org/jdtls/milestones/1.61.0/jdt-language-server-1.61.0-202609031315.tar.gz", + "sha256": "338e7e73d61836651ba2453919a0d34fa763eb4e7c03342092309bffb8934c64", + "archive": "tar.gz", + "home": "" + }, + { + "os": "macos", + "arch": "x86_64", + "url": "https://download.eclipse.org/jdtls/milestones/1.61.0/jdt-language-server-1.61.0-202609031315.tar.gz", + "sha256": "338e7e73d61836651ba2453919a0d34fa763eb4e7c03342092309bffb8934c64", + "archive": "tar.gz", + "home": "" + }, + { + "os": "windows", + "arch": "arm64", + "url": "https://download.eclipse.org/jdtls/milestones/1.61.0/jdt-language-server-1.61.0-202609031315.tar.gz", + "sha256": "338e7e73d61836651ba2453919a0d34fa763eb4e7c03342092309bffb8934c64", + "archive": "tar.gz", + "home": "" + }, + { + "os": "windows", + "arch": "x86_64", + "url": "https://download.eclipse.org/jdtls/milestones/1.61.0/jdt-language-server-1.61.0-202609031315.tar.gz", + "sha256": "338e7e73d61836651ba2453919a0d34fa763eb4e7c03342092309bffb8934c64", + "archive": "tar.gz", + "home": "" + } + ] + } + ] + }, "requiresTools": ["java", "jdtls-runtime"], "vendor": { "id": "io.github.lithe-idea", "displayName": "Lithe Community", "signatureRequirement": "none" }, - "permissions": ["backend.launch", "documents.contentProvider", "documents.read", "editor.actions", "languageServer.launch", "languageServer.request", "project.generate", "debug.launch", "debug.attach", "debug.start", "run.start", "window.messages", "workspace.metadata"], + "permissions": ["backend.launch", "runtimes.install", "documents.contentProvider", "documents.read", "editor.actions", "languageServer.launch", "languageServer.request", "project.generate", "debug.launch", "debug.attach", "debug.start", "run.start", "window.messages", "workspace.metadata"], "activationEvents": ["onLanguage:java", "onDebug:java"], "toolDefinitions": [ { @@ -322,7 +451,7 @@ "arguments": [ "-version" ], - "pattern": "version \\\"((?:2[1-9]|[3-9]\\d|\\d{3,})(?:\\.\\d+)*)" + "pattern": "version \\\"(25(?:\\.\\d+)*)[+_\\-\\\"]" }, "homeLayouts": [ { @@ -476,18 +605,6 @@ "platforms": [ "linux" ] - }, - { - "root": { - "kind": "home" - }, - "pattern": ".vscode/extensions/redhat.java-*/jre/*" - }, - { - "root": { - "kind": "home" - }, - "pattern": ".cursor/extensions/redhat.java-*/jre/*" } ], "commands": [ @@ -601,7 +718,7 @@ "id": "languageServerHome", "type": "directory", "title": "Language server folder", - "description": "Folder of the Eclipse JDT Language Server, the one that contains plugins and the config folders. Leave empty to find JDT LS installed with Homebrew, mason.nvim, Scoop or the VS Code Java extension, or through JDTLS_HOME or jdtls on PATH.", + "description": "Optional folder of the verified Eclipse JDT Language Server 1.61.0. Leave empty to reuse a compatible installation or let Lithe prepare the pinned server and its separate Java 25 runtime. This does not change the project JDK.", "default": "", "placeholder": "Automatic", "page": { diff --git a/scripts/compiler/test-live.mjs b/scripts/compiler/test-live.mjs index 750356e..aba8198 100644 --- a/scripts/compiler/test-live.mjs +++ b/scripts/compiler/test-live.mjs @@ -12,7 +12,7 @@ import {spawnSync} from 'node:child_process'; import {createHash} from 'node:crypto'; import {setTimeout as delay} from 'node:timers/promises'; import {Client} from '../package/lsp-client.mjs'; -import {serverInputs,answeredExecutable} from '../package/jdtls-test-inputs.mjs'; +import {serverInputs,answeredExecutable,preparedRuntimes} from '../package/jdtls-test-inputs.mjs'; const pkg=resolve(process.argv[2]??'.artifacts/package/arm64/io.github.lithe-idea.java-support'); const manifest=JSON.parse(readFileSync(join(pkg,'plugin.json'))); const stage=realpathSync.native(mkdtempSync(join(tmpdir(),'lithe-java-native-'))); @@ -46,7 +46,8 @@ try{ }; backend=new Client(join(pkg,manifest.backend.launch.path),[],{hostRequests}); await backend.request('initialize',{processId:process.pid,rootUri:pathToFileURL(root).href,capabilities:{experimental:{litheFunctions:{versions:[0]},litheLogging:{versions:[0]}}}});backend.notify('initialized',{}); - const params={serverID:'java',platform:{os:{darwin:'macos',win32:'windows'}[process.platform]??process.platform,arch:process.env.LITHE_TEST_ARCH??(process.arch==='arm64'?'arm64':'x86_64')},settings:{logLevel:'WARNING',languageServerHome:inputs.home},tools:{...inputs.tools,...projectJava()}}; + const params={serverID:'java',platform:{os:{darwin:'macos',win32:'windows'}[process.platform]??process.platform,arch:process.env.LITHE_TEST_ARCH??(process.arch==='arm64'?'arm64':'x86_64')},settings:{logLevel:'WARNING'},tools:{...inputs.tools,...projectJava()}}; + params.runtimes=await preparedRuntimes(backend,manifest,params.platform,inputs,`native-${++op}`); for(const[key,name]of Object.entries({stateDirectory:'state',workspaceStateDirectory:'workspace-state',logDirectory:'logs',temporaryDirectory:'tmp'})){params[key]=join(stage,name);mkdirSync(params[key]);} const launch=await backend.request('lithe/function/invoke',{functionID:'java.resolveLaunch',operationID:`native-${++op}`,params,context});configuration=launch.workspaceConfiguration; server=new Client(answeredExecutable(launch,inputs),launch.arguments,{env:{...process.env,...launch.environment},hostRequests:{'workspace/configuration':p=>p.items.map(item=>item.section?item.section.split('.').reduce((value,key)=>value?.[key],configuration)??null:configuration)}}); diff --git a/scripts/package/build-linux.mjs b/scripts/package/build-linux.mjs index 99060d1..5c18dc3 100644 --- a/scripts/package/build-linux.mjs +++ b/scripts/package/build-linux.mjs @@ -1,6 +1,6 @@ #!/usr/bin/env node // Linux packages carry the JDT LS extensions verified from their pins and a -// native backend from this source checkout; JDT LS and its JDK are the user's. +// native backend from this source checkout; the host prepares JDT LS and its JDK separately. // All writes are build outputs, never installed files. import {execFileSync} from 'node:child_process'; import {chmodSync,cpSync,mkdirSync,readFileSync,rmSync,mkdtempSync,readdirSync,lstatSync,writeFileSync} from 'node:fs'; @@ -33,7 +33,7 @@ function verify(directory){ verifyBinary(join(directory,manifest.backend.launch.path),arch,{executable:true}); if(readdirSync(join(directory,'jdtls-extensions')).sort().join()!==[...packaged].sort().join())throw Error('Unexpected JDT LS extension entries'); const walk=path=>{for(const name of readdirSync(path)){const file=join(path,name);const s=lstatSync(file);if(s.isSymbolicLink())throw Error(`Package link: ${file}`); - // JDT LS and the JDK are the user's; finding either means a build copied it in. + // JDT LS and the JDK belong in the managed cache, not in the plugin package. if((s.isFile()&&/^org\.eclipse\.equinox\.launcher_.*\.jar$|^java$|^libjvm\.so$/.test(name))||(s.isDirectory()&&/^config_/.test(name)))throw Error(`Package must not contain JDT LS or a JDK: ${file}`); if(s.isDirectory())walk(file);}};walk(directory); verifyNotices(directory); diff --git a/scripts/package/host-managed-runtime_test.go b/scripts/package/host-managed-runtime_test.go new file mode 100644 index 0000000..e14b90a --- /dev/null +++ b/scripts/package/host-managed-runtime_test.go @@ -0,0 +1,160 @@ +// This integration fixture belongs to the Java plugin, not the generic host. +// test-host-managed.mjs overlays it into a matching host checkout for execution. +// It uses the real Core contract, SDK backend, host service and runtime manager. +// Only HTTPS transport is replaced with previously verified official archives. +package pluginservice_test + +import ( + "context" + "crypto/sha256" + "encoding/hex" + "encoding/json" + "fmt" + "io" + "net/http" + "os" + "path/filepath" + "reflect" + "runtime" + "sync" + "testing" + "time" + + "github.com/1lck/Lithe-IDEA/desktop/internal/core" + "github.com/1lck/Lithe-IDEA/desktop/internal/marketplace" + "github.com/1lck/Lithe-IDEA/desktop/internal/pluginservice" + "github.com/1lck/Lithe-IDEA/desktop/internal/store" +) + +type javaArchiveTransport func(*http.Request) (*http.Response, error) + +func (f javaArchiveTransport) RoundTrip(request *http.Request) (*http.Response, error) { + return f(request) +} + +func TestJavaManagedRuntimeOfficialArchives(t *testing.T) { + if runtime.GOOS != "linux" || runtime.GOARCH != "amd64" { + t.Skip("This native verification lane currently supplies Linux x64 official archives") + } + pkg := os.Getenv("LITHE_MANAGED_TEST_PACKAGE") + if pkg == "" { + t.Fatal("Run scripts/package/test-host-managed.mjs with a built Java plugin ZIP") + } + manifest, err := os.ReadFile(filepath.Join(pkg, "plugin.json")) + if err != nil { + t.Fatal(err) + } + var declaration map[string]any + if err := json.Unmarshal(manifest, &declaration); err != nil { + t.Fatal(err) + } + pluginID, version := declaration["id"].(string), declaration["version"].(string) + ctx, cancel := context.WithTimeout(context.Background(), 180*time.Second) + defer cancel() + kernel := core.NewClient() + plan, err := kernel.PlanManagedRuntimes(ctx, manifest, core.ManagedRuntimePlatform{OS: "linux", Arch: "x86_64"}) + if err != nil { + t.Fatal(err) + } + paths := map[string]string{ + "jdk": os.Getenv("LITHE_MANAGED_TEST_JDK_ARCHIVE"), + "jdtls": os.Getenv("LITHE_MANAGED_TEST_JDTLS_ARCHIVE"), + } + byURL := make(map[string]string) + for _, dependency := range plan.Dependencies { + path := paths[dependency.ID] + file, err := os.Open(path) + if err != nil { + t.Fatal(err) + } + hash := sha256.New() + _, readErr := io.Copy(hash, file) + closeErr := file.Close() + if readErr != nil || closeErr != nil || hex.EncodeToString(hash.Sum(nil)) != dependency.SHA256 { + t.Fatalf("Official archive checksum mismatch for %s", dependency.ID) + } + byURL[dependency.URL] = dependency.ID + } + service, err := pluginservice.Open(kernel, store.At(t.TempDir()), t.TempDir()) + if err != nil { + t.Fatal(err) + } + service.SetRuntimeLanguage("zh-CN") + var lock sync.Mutex + downloads := make(map[string]int) + service.RuntimeDownloader = marketplace.NewArchiveDownloader(&http.Client{Transport: javaArchiveTransport(func(request *http.Request) (*http.Response, error) { + id, exists := byURL[request.URL.String()] + if !exists { + return nil, fmt.Errorf("unexpected archive request") + } + file, err := os.Open(paths[id]) + if err != nil { + return nil, err + } + info, err := file.Stat() + if err != nil { + _ = file.Close() + return nil, err + } + lock.Lock() + downloads[id]++ + lock.Unlock() + return &http.Response{StatusCode: http.StatusOK, Header: make(http.Header), Body: file, ContentLength: info.Size(), Request: request}, nil + })}) + service.RuntimeIssue = func(_ context.Context, failure error) { t.Logf("Runtime recovery category: %T", failure) } + first, err := service.EnsureRuntimes(ctx, manifest, pkg, pluginID, version, true, nil) + if err != nil { + t.Fatal(err) + } + if !reflect.DeepEqual(downloads, map[string]int{"jdk": 1, "jdtls": 1}) { + t.Fatalf("Expected a clean runner with both dependencies absent; transfers: %v", downloads) + } + if len(first.Runtimes) != 2 || len(first.Tools) != 1 || first.Tools["jdtls-runtime"].Path == "" { + t.Fatalf("incomplete service environment: %+v", first) + } + if _, exists := first.Tools["java"]; exists { + t.Fatal("managed service JDK changed the project java tool") + } + for _, installation := range first.Runtimes { + if filepath.Dir(installation.Home) == pkg { + t.Fatal("runtime was written inside the plugin package") + } + } + second, err := service.EnsureRuntimes(ctx, manifest, pkg, pluginID, version, false, nil) + if err != nil || !reflect.DeepEqual(first.Runtimes, second.Runtimes) { + t.Fatalf("startup did not reuse prepared paths: %v", err) + } + // Only the plugin version changes: the runtime artifact identities do not. + declaration["version"] = "99.0.0" + updated, err := json.Marshal(declaration) + if err != nil { + t.Fatal(err) + } + third, err := service.EnsureRuntimes(ctx, updated, pkg, pluginID, "99.0.0", true, nil) + if err != nil || !reflect.DeepEqual(first.Runtimes, third.Runtimes) { + t.Fatalf("plugin update did not reuse prepared paths: %v", err) + } + if !reflect.DeepEqual(downloads, map[string]int{"jdk": 1, "jdtls": 1}) { + t.Fatalf("startup or update downloaded a second copy: %v", downloads) + } + // Damage only the isolated test cache, retaining the verified source archive. + oldJDK := first.Runtimes["jdk"].Home + if err := os.Remove(filepath.Join(oldJDK, "bin", "javac")); err != nil { + t.Fatal(err) + } + repaired, err := service.EnsureRuntimes(ctx, updated, pkg, pluginID, "99.0.0", false, nil) + if err != nil { + t.Fatal(err) + } + if repaired.Runtimes["jdk"].Home == oldJDK || repaired.Runtimes["jdtls"] != first.Runtimes["jdtls"] { + t.Fatal("repair did not replace just the damaged dependency") + } + if !reflect.DeepEqual(downloads, map[string]int{"jdk": 1, "jdtls": 1}) { + t.Fatalf("repair should reuse verified archive bytes without another transfer: %v", downloads) + } + after, err := os.ReadFile(filepath.Join(pkg, "plugin.json")) + if err != nil || string(after) != string(manifest) { + t.Fatal("preparation changed the installed plugin manifest") + } + t.Log("Real Java backend + Core + host: official archives verified/extracted, startup/update zero transfers, separate service tool, damaged JDK repaired from cached archive") +} diff --git a/scripts/package/jdtls-runtime-profile.mjs b/scripts/package/jdtls-runtime-profile.mjs new file mode 100644 index 0000000..f1a7b26 --- /dev/null +++ b/scripts/package/jdtls-runtime-profile.mjs @@ -0,0 +1,29 @@ +// Pin the files loaded by the language service independently of plugin releases. +// Run only after prepare-jdtls.sh has checked the upstream archive SHA-256. +import assert from 'node:assert/strict'; +import {createHash} from 'node:crypto'; +import {readFileSync,readdirSync,lstatSync,writeFileSync} from 'node:fs'; +import {dirname,join,relative,resolve} from 'node:path'; +import {fileURLToPath} from 'node:url'; + +const root=resolve(dirname(fileURLToPath(import.meta.url)),'../..'); +const server=resolve(process.argv[2]??join(root,'.artifacts/jdtls')); +const pins=JSON.parse(readFileSync(join(root,'third_party/jdtls/manifest.json'),'utf8')); +const target=join(root,'third_party/jdtls/runtime-files.json'); +const record=path=>{ + const stat=lstatSync(path); + assert.ok(stat.isFile()&&!stat.isSymbolicLink(),`Expected upstream regular file: ${path}`); + return {path:relative(server,path).split('\\').join('/'),size:stat.size,sha256:createHash('sha256').update(readFileSync(path)).digest('hex')}; +}; +const files=[]; +const walk=path=>{ + const stat=lstatSync(path);assert.ok(!stat.isSymbolicLink(),`Unexpected upstream link: ${path}`); + if(stat.isDirectory())for(const name of readdirSync(path).sort())walk(join(path,name)); + else files.push(record(path)); +}; +walk(join(server,'plugins')); +const configurations={}; +for(const name of readdirSync(server).filter(name=>name.startsWith('config_')).sort())configurations[name]=record(join(server,name,'config.ini')); +const profile={version:pins.version,archiveSHA256:pins.archiveSHA256,files,configurations}; +if(process.argv.includes('--write'))writeFileSync(target,JSON.stringify(profile,null,2)+'\n'); +else assert.deepEqual(profile,JSON.parse(readFileSync(target,'utf8')),'The verified JDT LS file profile differs; update it only with a reviewed upstream version change'); diff --git a/scripts/package/jdtls-test-inputs.mjs b/scripts/package/jdtls-test-inputs.mjs index 1f9b737..d0fa58e 100644 --- a/scripts/package/jdtls-test-inputs.mjs +++ b/scripts/package/jdtls-test-inputs.mjs @@ -1,27 +1,54 @@ -// What an integration test passes for the user's own JDT LS and the JDK it -// runs on, which the package does not ship. LITHE_TEST_JDTLS_HOME names the +// What an integration test passes for the separately prepared JDT LS and JDK. +// Neither is stored inside the plugin ZIP. LITHE_TEST_JDTLS_HOME names the // JDT LS folder (default: the tested release scripts/prepare-jdtls.sh -// prepared in .artifacts/jdtls); LITHE_TEST_JDTLS_JAVA names a Java 21+ +// prepared in .artifacts/jdtls); LITHE_TEST_JDTLS_JAVA names a full Java 25 // executable (default: JAVA_HOME's, then java on PATH). The launch answers the // jdtls-runtime tool, which the host would resolve; tests resolve it here. import assert from 'node:assert/strict'; import {spawnSync} from 'node:child_process'; -import {existsSync} from 'node:fs'; +import {existsSync,realpathSync} from 'node:fs'; import {dirname,join,resolve} from 'node:path'; import {fileURLToPath} from 'node:url'; +import {prepareTestJDK} from './prepare-test-jdk.mjs'; const root=resolve(dirname(fileURLToPath(import.meta.url)),'../..'); export const SERVER_RUNTIME_TOOL='jdtls-runtime'; export function serverInputs(){ const home=resolve(process.env.LITHE_TEST_JDTLS_HOME??join(root,'.artifacts/jdtls')); assert.ok(existsSync(join(home,'plugins')),`No JDT LS installation at ${home}; run scripts/prepare-jdtls.sh or set LITHE_TEST_JDTLS_HOME`); const exe=process.platform==='win32'?'java.exe':'java'; - const java=process.env.LITHE_TEST_JDTLS_JAVA??(process.env.JAVA_HOME?join(process.env.JAVA_HOME,'bin',exe):'java'); + let java=process.env.LITHE_TEST_JDTLS_JAVA??(process.env.JAVA_HOME?join(process.env.JAVA_HOME,'bin',exe):'java'); // `java -version` prints to stderr; the pattern is the tool definition's. - const probe=spawnSync(java,['-version'],{encoding:'utf8',timeout:15000,windowsHide:true}); + const run=()=>spawnSync(java,['-XshowSettings:properties','-version'],{encoding:'utf8',timeout:15000,windowsHide:true}); + let probe=run(); + // Honor explicit test input failures. Without one, prepare the manifest pin + // when the existing runner only has the JDK used for extension compilation. + if(!process.env.LITHE_TEST_JDTLS_JAVA&&(probe.status!==0||!/version "25(?:[.\-+_"])/.test(probe.stderr))){java=prepareTestJDK();probe=run();} assert.equal(probe.status,0,`${java} -version failed: ${probe.error?.message??probe.stderr}`); const version=/version "(?:1\.)?(\d+(?:\.\d+)*)/.exec(probe.stderr)?.[1]; - assert.ok(version && Number(version.split('.')[0])>=21,`JDT LS needs Java 21 or later, ${java} is ${version}`); - return {home,java,tools:{[SERVER_RUNTIME_TOOL]:{executable:java,version}}}; + assert.ok(version && Number(version.split('.')[0])===25,`This verified JDT LS environment uses Java 25, ${java} is ${version}`); + const jdkHome=/^\s*java\.home = (.+)$/m.exec(probe.stderr)?.[1]?.trim(); + assert.ok(jdkHome&&existsSync(join(jdkHome,'bin',process.platform==='win32'?'javac.exe':'javac')),'The language service needs a full JDK 25'); + return {home,java,jdkHome:realpathSync(jdkHome),tools:{[SERVER_RUNTIME_TOOL]:{executable:java,home:realpathSync(jdkHome),version}}}; +} + +// Exercise the same read-only hook the host calls before downloading anything. +// The caller owns fetching and integrity checking; these paths are already +// prepared inputs. Using the returned map also tests the normal launch path. +export async function preparedRuntimes(backend,manifest,platform,inputs,operationID){ + const dependencies=manifest.managedRuntimes.dependencies.map(dependency=>{ + const artifact=dependency.artifacts.find(value=>value.os===platform.os&&value.arch===platform.arch); + assert.ok(artifact,`No managed runtime for ${platform.os}/${platform.arch}`); + const {artifacts,...declaration}=dependency; + return {...declaration,...artifact}; + }); + const params={platform,dependencies,candidates:{jdk:inputs.jdkHome,jdtls:inputs.home},tools:inputs.tools,settings:{},language:'en'}; + const result=await backend.request('lithe/function/invoke',{functionID:manifest.managedRuntimes.resolve.function,operationID,params}); + assert.deepEqual(result.missing,[]); + assert.equal(result.runtimes.length,2); + const runtimes=Object.fromEntries(result.runtimes.map(({id,...value})=>[id,value])); + assert.equal(realpathSync(runtimes.jdk.home),inputs.jdkHome); + assert.equal(realpathSync(runtimes.jdtls.home),realpathSync(inputs.home)); + return runtimes; } // The program a launch answer runs: the runtime tool resolves to the test JDK. export function answeredExecutable(launch,inputs){ diff --git a/scripts/package/prepare-test-jdk.mjs b/scripts/package/prepare-test-jdk.mjs new file mode 100644 index 0000000..e78bf02 --- /dev/null +++ b/scripts/package/prepare-test-jdk.mjs @@ -0,0 +1,48 @@ +// Build/test support only. Production installation is the host's managed +// runtime service. Existing CI may compile the extension on JDK 21; this +// helper prepares the same pinned full JDK 25 to run the language service. +import assert from 'node:assert/strict'; +import {execFileSync} from 'node:child_process'; +import {createHash} from 'node:crypto'; +import {closeSync,existsSync,mkdirSync,mkdtempSync,openSync,readFileSync,readSync,renameSync,rmSync} from 'node:fs'; +import {basename,dirname,join,resolve} from 'node:path'; +import {fileURLToPath} from 'node:url'; + +const root=resolve(dirname(fileURLToPath(import.meta.url)),'../..'); +function digest(path){ + const file=openSync(path,'r'),hash=createHash('sha256'),buffer=Buffer.alloc(64*1024); + try{for(;;){const count=readSync(file,buffer);if(!count)break;hash.update(buffer.subarray(0,count));}return hash.digest('hex');} + finally{closeSync(file);} +} +export function prepareTestJDK(){ + const os={darwin:'macos',win32:'windows'}[process.platform]??process.platform; + const arch={arm64:'arm64',x64:'x86_64'}[process.arch]; + const manifest=JSON.parse(readFileSync(join(root,'io.github.lithe-idea.java-support/plugin.json'))); + const artifact=manifest.managedRuntimes.dependencies.find(value=>value.id==='jdk').artifacts.find(value=>value.os===os&&value.arch===arch); + assert.ok(artifact,`No full test JDK is declared for ${os}/${arch}`); + const cache=join(root,'.artifacts/managed-jdk'),directory=join(cache,artifact.sha256); + const home=join(directory,artifact.stripPrefix,artifact.home??''); + const executable=join(home,artifact.executable); + const suffix=os==='windows'?'.exe':''; + if([executable,join(home,`bin/javac${suffix}`),join(home,'release'),join(home,'lib/modules'),join(home,'jmods/java.base.jmod')].every(existsSync))return executable; + mkdirSync(cache,{recursive:true}); + const archive=join(cache,basename(new URL(artifact.url).pathname)); + if(!existsSync(archive)||digest(archive)!==artifact.sha256){ + const partial=`${archive}.${process.pid}.partial`; + try{ + execFileSync('curl',['--fail','--silent','--show-error','--location','--proto','=https','--proto-redir','=https','--connect-timeout','30','--max-time','300','--output',partial,artifact.url],{stdio:'inherit',timeout:320000,windowsHide:true}); + assert.equal(digest(partial),artifact.sha256,'Official full JDK archive checksum mismatch'); + renameSync(partial,archive); + }finally{rmSync(partial,{force:true});} + } + const staging=mkdtempSync(join(cache,'.jdk-stage-')); + try{ + // Only bytes matching a reviewed official archive digest are extracted. + // Windows' system bsdtar supports the pinned ZIP; Unix inputs are tar.gz. + const tar=os==='windows'?join(process.env.SystemRoot??'C:\\Windows','System32/tar.exe'):'tar'; + execFileSync(tar,['-xf',archive,'-C',staging],{stdio:'inherit',timeout:180000,windowsHide:true}); + assert.ok(existsSync(join(staging,artifact.stripPrefix,artifact.home??'',`bin/javac${suffix}`)),'Archive does not contain a full JDK'); + rmSync(directory,{recursive:true,force:true});renameSync(staging,directory); + return executable; + }finally{rmSync(staging,{recursive:true,force:true});} +} diff --git a/scripts/package/project-model-bundle.mjs b/scripts/package/project-model-bundle.mjs index 72a425b..8f48b8e 100644 --- a/scripts/package/project-model-bundle.mjs +++ b/scripts/package/project-model-bundle.mjs @@ -1,9 +1,9 @@ #!/usr/bin/env node // Builds the plugin's own JDT LS extension bundle (jdtls-extension/project-model) // into /project-model/. It is compiled against the JDT LS release -// prepared by scripts/prepare-jdtls.sh, the release the tests run; the bundle -// only uses APIs JDT has kept since its 3.x releases, so a user's newer JDT LS -// loads it too. The jar is reproducible: entries are sorted and dated +// prepared by scripts/prepare-jdtls.sh, also pinned for managed installation. +// Other JDT LS releases need a new compatibility qualification. The jar is +// reproducible: entries are sorted and dated // BUNDLE_DATE, so the same sources and JDK give the same bytes. // Usage: node scripts/package/project-model-bundle.mjs import { execFileSync } from 'node:child_process'; @@ -16,8 +16,8 @@ const root = resolve(dirname(fileURLToPath(import.meta.url)), '../..'); export const BUNDLE_SOURCE = join(root, 'jdtls-extension/project-model'); export const BUNDLE_DIRECTORY = 'project-model'; export const BUNDLE_DATE = '2026-01-01T00:00:00Z'; -// The oldest Java a supported JDT LS runs on is 21; 17 keeps the class files -// loadable by every JDK the user may still point JDT LS at. +// Keep the existing extension bytecode baseline; the complete verified +// language-service environment runs on Java 25. const RELEASE = '17'; /** The bundle's jar name, from its manifest's symbolic name and version. */ diff --git a/scripts/package/smoke-linux.mjs b/scripts/package/smoke-linux.mjs index c5075bd..18106af 100644 --- a/scripts/package/smoke-linux.mjs +++ b/scripts/package/smoke-linux.mjs @@ -1,31 +1,38 @@ // Native integration test of the extracted archive and its read-only boundary. import assert from 'node:assert/strict'; import {execFileSync} from 'node:child_process'; -import {mkdtempSync,mkdirSync,rmSync,readFileSync,readdirSync,lstatSync,writeFileSync} from 'node:fs'; +import {mkdtempSync,mkdirSync,rmSync,readFileSync,readdirSync,lstatSync,readlinkSync,writeFileSync} from 'node:fs'; import {tmpdir} from 'node:os'; import {join,resolve} from 'node:path'; import {pathToFileURL} from 'node:url'; import {createHash} from 'node:crypto'; import {Client} from './lsp-client.mjs'; -import {serverInputs,answeredExecutable} from './jdtls-test-inputs.mjs'; +import {serverInputs,answeredExecutable,preparedRuntimes} from './jdtls-test-inputs.mjs'; const archive=resolve(process.argv[2]); assert.equal(process.platform,'linux'); const inputs=serverInputs(); const stage=mkdtempSync(join(tmpdir(),'lithe-java-linux-'));let backend,server; const serverBefore=()=>inventory(inputs.home); const inventory=root=>{ - const entries=[];const walk=(path,relative)=>{const s=lstatSync(path);assert.ok(!s.isSymbolicLink());entries.push([relative,s.mode,s.isFile()?createHash('sha256').update(readFileSync(path)).digest('hex'):null]);if(s.isDirectory())for(const name of readdirSync(path).sort())walk(join(path,name),`${relative}/${name}`);};walk(root,'');return entries; + const entries=[];const walk=(path,relative)=>{const s=lstatSync(path);entries.push([relative,s.mode,s.isSymbolicLink()?readlinkSync(path):s.isFile()?createHash('sha256').update(readFileSync(path)).digest('hex'):null]);if(s.isDirectory())for(const name of readdirSync(path).sort())walk(join(path,name),`${relative}/${name}`);};walk(root,'');return entries; }; try{ execFileSync('unzip',['-q',archive,'-d',stage],{timeout:120000}); - const pkg=join(stage,'io.github.lithe-idea.java-support');const before=inventory(pkg);const serverBaseline=serverBefore(); + const pkg=join(stage,'io.github.lithe-idea.java-support');const before=inventory(pkg);const serverBaseline=serverBefore();const jdkBaseline=inventory(inputs.jdkHome); + const manifest=JSON.parse(readFileSync(join(pkg,'plugin.json'))); const workspace=join(stage,'workspace');mkdirSync(workspace);writeFileSync(join(workspace,'Hello.java'),'class Hello { String value; }\n'); - const params={serverID:'java',platform:{os:'linux',arch:process.arch==='arm64'?'arm64':'x86_64'},settings:{logLevel:'WARNING',languageServerHome:inputs.home},tools:inputs.tools}; + const params={serverID:'java',platform:{os:'linux',arch:process.arch==='arm64'?'arm64':'x86_64'},settings:{logLevel:'WARNING'},tools:inputs.tools}; for(const [key,name] of Object.entries({stateDirectory:'state',workspaceStateDirectory:'workspace-state',logDirectory:'logs',temporaryDirectory:'tmp'})){params[key]=join(stage,name);mkdirSync(params[key]);} backend=new Client(join(pkg,'bin/lithe-java-backend')); const initialized=await backend.request('initialize',{rootUri:pathToFileURL(workspace).href,capabilities:{experimental:{litheFunctions:{versions:[0]},litheLogging:{versions:[0]}}}}); assert.ok(initialized.capabilities.experimental.litheFunctions); backend.notify('initialized',{}); + const first=performance.now(); + params.runtimes=await preparedRuntimes(backend,manifest,params.platform,inputs,'linux-prepare-first'); + const qualifiedMilliseconds=performance.now()-first; + const again=performance.now(); + assert.deepEqual(await preparedRuntimes(backend,manifest,params.platform,inputs,'linux-prepare-again'),params.runtimes); + const repeatedMilliseconds=performance.now()-again; const launch=await backend.request('lithe/function/invoke',{functionID:'java.resolveLaunch',operationID:'linux-smoke',params}); assert.ok(launch.writablePaths.every(path=>!path.startsWith(pkg+'/')&&!path.startsWith(inputs.home+'/'))); const runtime=answeredExecutable(launch,inputs); @@ -36,7 +43,8 @@ try{ await backend.close();backend=undefined; assert.deepEqual(inventory(pkg),before,'LSP startup must not change installed package files or permissions'); assert.deepEqual(serverBefore(),serverBaseline,'LSP startup must not write into the user\'s JDT LS installation'); - console.log(`Verified Linux ${process.arch}: backend handshake, launch resolution of the user's JDT LS, initialize/shutdown, immutable package and installation`); + assert.deepEqual(inventory(inputs.jdkHome),jdkBaseline,'LSP startup must not change the full JDK'); + console.log(`Verified Linux ${process.arch}: repeatable managed-runtime qualification (${qualifiedMilliseconds.toFixed(1)} / ${repeatedMilliseconds.toFixed(1)} ms), approved-map launch, initialize/shutdown, immutable package, JDT LS and full JDK`); }finally{ try{if(server)await server.close();}finally{try{if(backend)await backend.close();}finally{rmSync(stage,{recursive:true,force:true});}} } diff --git a/scripts/package/test-host-managed.mjs b/scripts/package/test-host-managed.mjs new file mode 100644 index 0000000..090dc38 --- /dev/null +++ b/scripts/package/test-host-managed.mjs @@ -0,0 +1,31 @@ +// Executes the Java-owned integration fixture against a corresponding host +// checkout without writing test code into that repository. Go's overlay is +// temporary; package, preferences, runtime cache and processes are test-owned. +import assert from 'node:assert/strict'; +import {execFileSync} from 'node:child_process'; +import {existsSync,mkdtempSync,mkdirSync,readFileSync,rmSync,writeFileSync} from 'node:fs'; +import {dirname,join,resolve} from 'node:path'; +import {fileURLToPath} from 'node:url'; + +const root=resolve(dirname(fileURLToPath(import.meta.url)),'../..'); +const [hostArg,archiveArg]=process.argv.slice(2); +assert.ok(hostArg&&archiveArg,'Usage: node scripts/package/test-host-managed.mjs '); +assert.equal(process.platform,'linux'); +assert.equal(process.arch,'x64'); +const host=resolve(hostArg),archive=resolve(archiveArg); +const jdk=process.env.LITHE_MANAGED_TEST_JDK_ARCHIVE??join(root,'.artifacts/managed-jdk/microsoft-jdk-25.0.5.0.2-linux-x64.tar.gz'); +const pins=JSON.parse(readFileSync(join(root,'third_party/jdtls/manifest.json'))); +const server=process.env.LITHE_MANAGED_TEST_JDTLS_ARCHIVE??join(root,`.artifacts/jdtls-downloads/jdtls-${pins.version}-${pins.archiveSHA256}.tar.gz`); +assert.ok(existsSync(jdk)&&existsSync(server),'Download the exact official archives before running this integration lane'); +mkdirSync(join(root,'.artifacts'),{recursive:true}); +const stage=mkdtempSync(join(root,'.artifacts/host-managed-')); +try{ + const pkgRoot=join(stage,'package');mkdirSync(pkgRoot); + execFileSync('unzip',['-q',archive,'-d',pkgRoot],{timeout:120000}); + const overlay=join(stage,'overlay.json'); + writeFileSync(overlay,JSON.stringify({Replace:{[join(host,'desktop/internal/pluginservice/zz_java_managed_integration_test.go')]:join(root,'scripts/package/host-managed-runtime_test.go')}})); + execFileSync(join(host,'scripts/desktop/desktop-go.sh'),['test',`-overlay=${overlay}`,'./internal/pluginservice','-run','^TestJavaManagedRuntimeOfficialArchives$','-count=1','-v','-timeout=240s'],{ + cwd:host,stdio:'inherit',timeout:600000, + env:{...process.env,LITHE_MANAGED_TEST_PACKAGE:join(pkgRoot,'io.github.lithe-idea.java-support'),LITHE_MANAGED_TEST_JDK_ARCHIVE:jdk,LITHE_MANAGED_TEST_JDTLS_ARCHIVE:server}, + }); +}finally{rmSync(stage,{recursive:true,force:true});} diff --git a/scripts/prepare-jdtls.sh b/scripts/prepare-jdtls.sh index 072bc68..78577b7 100755 --- a/scripts/prepare-jdtls.sh +++ b/scripts/prepare-jdtls.sh @@ -152,9 +152,10 @@ validate_output() { [[ -f "$OUTPUT_DIR/java-test/runner/$java_test_runner_name" ]] || { print -u2 -- "Java Test runner is missing: $OUTPUT_DIR"; exit 1; } [[ -f "$OUTPUT_DIR/java-test/LICENSE-MIT.txt" ]] || { print -u2 -- "Java Test license is missing: $OUTPUT_DIR"; exit 1; } # Wrapper scripts remain available for external/legacy launch plans. The - # packaged product launches bundled Java directly with the resources above. + # packaged product launches the selected service JDK directly with these resources. grep -Fq -- '-javaagent:' "$OUTPUT_DIR/bin/jdtls" || { print -u2 -- "JDTLS launcher does not load the Lombok agent: $OUTPUT_DIR"; exit 1; } grep -Fq -- '-javaagent:' "$OUTPUT_DIR/bin/jdtls.ps1" || { print -u2 -- "JDTLS Windows launcher does not load the Lombok agent: $OUTPUT_DIR"; exit 1; } + node "$ROOT_DIR/scripts/package/jdtls-runtime-profile.mjs" "$OUTPUT_DIR" } if [[ -n "${LITHE_JDTLS_ROOT:-}" ]]; then diff --git a/scripts/verify-contract.py b/scripts/verify-contract.py new file mode 100644 index 0000000..831e136 --- /dev/null +++ b/scripts/verify-contract.py @@ -0,0 +1,66 @@ +#!/usr/bin/env python3 +"""Validate package declarations using schemas from the separately pinned Core. + +The SDK transport pin stays independent of newer declarative capabilities. +All schema references resolve from the checksum-verified in-memory registry; +the validator never follows a rolling main-branch reference over the network. +""" + +import argparse +import hashlib +import json +from pathlib import Path +import urllib.request + +from jsonschema import Draft202012Validator +from referencing import Registry, Resource + + +def main(): + parser = argparse.ArgumentParser() + parser.add_argument("--download", action="store_true") + args = parser.parse_args() + root = Path(__file__).resolve().parent.parent + lock = json.loads((root / "contract.lock.json").read_text()) + revision = lock["commit"] + assert len(revision) == 40 and all(char in "0123456789abcdef" for char in revision) + assert lock["repository"] == "https://github.com/Lithe-IDEA/Lithe-core-rust" + base = f"https://raw.githubusercontent.com/Lithe-IDEA/Lithe-core-rust/{revision}/shared/plugins/contract/v1/" + cache = root / ".artifacts/contracts" / revision + schemas = {} + registry = Registry() + for record in lock["schemas"]: + name = record["path"] + assert name in {"plugin-manifest.schema.json", "native-ui.schema.json", "plugin-l10n.schema.json"} + path = cache / name + if not path.exists(): + if not args.download: + raise RuntimeError("Missing pinned schema cache; run scripts/verify-sdk-lock.sh --download") + with urllib.request.urlopen(base + name, timeout=30) as response: + content = response.read(2 * 1024 * 1024 + 1) + assert len(content) <= 2 * 1024 * 1024, "Schema exceeds the download limit" + else: + content = path.read_bytes() + assert hashlib.sha256(content).hexdigest() == record["sha256"], f"Pinned schema checksum mismatch: {name}" + schema = json.loads(content) + Draft202012Validator.check_schema(schema) + schemas[name] = schema + registry = registry.with_resource(schema["$id"], Resource.from_contents(schema)) + cache.mkdir(parents=True, exist_ok=True) + if not path.exists(): + path.write_bytes(content) + + package = root / "io.github.lithe-idea.java-support" + inputs = [(package / "plugin.json", "plugin-manifest.schema.json")] + inputs.extend((path, "plugin-l10n.schema.json") for path in sorted((package / "l10n").glob("*.json"))) + for path, schema in inputs: + validator = Draft202012Validator(schemas[schema], registry=registry) + failures = sorted(validator.iter_errors(json.loads(path.read_text())), key=lambda error: str(error.path)) + if failures: + details = "\n".join(f"{path.name}: {list(error.path)}: {error.message}" for error in failures) + raise RuntimeError(details) + print(f"Verified manifest and {len(inputs) - 1} translations against Core {revision}") + + +if __name__ == "__main__": + main() diff --git a/scripts/verify-sdk-lock.sh b/scripts/verify-sdk-lock.sh index d254625..6664a52 100755 --- a/scripts/verify-sdk-lock.sh +++ b/scripts/verify-sdk-lock.sh @@ -13,3 +13,17 @@ case "${1:-}" in esac cargo test --locked --manifest-path "$ROOT_DIR/Cargo.toml" -p lithe-java-backend \ --test repository_pins cargo_resolves_the_sdk_commit_recorded_in_the_lock + +# The existing CI and release checks call this script. Declarative capabilities +# can require a newer Core schema without changing the backend's SDK transport. +# Keep Python tooling isolated from the machine's packages and pin its versions. +CONTRACT_VALIDATOR_DIR="$ROOT_DIR/.artifacts/contract-validator" +if [[ ! -f "$CONTRACT_VALIDATOR_DIR/pyvenv.cfg" ]]; then + python3 -m venv "$CONTRACT_VALIDATOR_DIR" +fi +CONTRACT_PYTHON="$CONTRACT_VALIDATOR_DIR/bin/python" +if [[ ! -x "$CONTRACT_PYTHON" ]]; then + CONTRACT_PYTHON="$CONTRACT_VALIDATOR_DIR/Scripts/python.exe" +fi +"$CONTRACT_PYTHON" -m pip install --quiet --disable-pip-version-check 'jsonschema==4.26.0' 'referencing==0.37.0' +"$CONTRACT_PYTHON" "$ROOT_DIR/scripts/verify-contract.py" "$@" diff --git a/third_party/README.md b/third_party/README.md index 39a7be7..96474b6 100644 --- a/third_party/README.md +++ b/third_party/README.md @@ -1,24 +1,21 @@ # 第三方输入 -`third_party/` 只记录插件包需要的上游输入,每个组件一个 `manifest.json`:上游版本、HTTPS 下载地址和 SHA-256。 +插件包和独立运行环境均使用固定上游版本、HTTPS 地址和 SHA-256。仓库只保存清单、许可证和运行环境文件指纹,不提交上游发布二进制。 | 清单 | 内容 | 使用者 | | --- | --- | --- | -| `jdtls/manifest.json` | 随包的 Lombok、java-debug、vscode-java-test 扩展,以及测试用 Eclipse JDT Language Server 的版本、下载地址和 SHA-256;`minimumJavaVersion` 是运行 JDT LS 的最低 Java 版本,与后端的 `MINIMUM_SERVER_JAVA_VERSION` 一致 | `scripts/prepare-jdtls.sh` | +| `jdtls/manifest.json` | Eclipse JDT LS 1.61.0、Lombok、java-debug、vscode-java-test 的固定下载输入;`minimumJavaVersion: 21` 是这个上游 JDT LS 的实际最低 Java 版本 | `scripts/prepare-jdtls.sh`、扩展打包、真实服务器测试 | +| `jdtls/runtime-files.json` | 该 JDT LS 原始归档的所有 114 个插件文件及五个平台配置模板的大小与 SHA-256 | `java.resolveRuntimes` 和启动前兼容性检查 | +| `../io.github.lithe-idea.java-support/plugin.json` 的 `managedRuntimes` | 与上述清单一致的 JDT LS 及六个平台完整 Microsoft JDK 25.0.5.0.2 的下载锁 | 宿主通用运行环境安装器 | -插件包不带 JDT LS 和 JDK:插件运行用户自己安装的 JDT LS 和 JDK 21+(`backend/src/jdtls.rs`)。清单里的 JDT LS -只用于构建和测试:组装时据它的 `plugins/` 剔除 JDT LS 已自带的 Java Test 扩展包,集成测试把它当作用户的安装来启动。 +语言服务选择完整 JDK 25 是本插件的验证策略,不把 JDT LS 1.61.0 的上游最低要求误写成 25。项目的 JDK 和 source/target/release 与它分开。插件 ZIP 不包含 JDT LS / JDK;宿主安装时先检查可复用的外部或缓存安装,仅下载缺失依赖。 -规则: +构建脚本把下载物放在被忽略的 `.artifacts/`,先校验 SHA-256 再使用。组装时用固定 JDT LS 的 `plugins/` 剔除它已包含的 Java Test 扩展包,并检查运行环境文件指纹一致。随包第三方许可证从上游复制,`NOTICE` 列出许可。运行环境按完整上游归档安装,保留其许可证与第三方 notices。 -- 下载物放在被 `.gitignore` 忽略的 `.artifacts/` 下,先校验 SHA-256 再使用;缓存校验失败时删除重下。 - 不要把 jar、JDK 或其他发布二进制提交到仓库。 -- 升级组件时同时改版本、地址和 SHA-256,并在 PR 里写明上游发布页。`cargo test` 会检查每个地址都是 - HTTPS、每个校验和都是小写 SHA-256(`backend/tests/repository_pins.rs`)。 -- 插件包里的第三方许可证由组装脚本从上游包复制,`scripts/verify-package.sh` 检查它们存在;仓库根目录的 - `NOTICE` 列出全部组件和许可。 +升级某个依赖时同时更新版本、不可变地址、SHA-256;JDT LS 还需更新运行环境 profile 与扩展兼容性验证,不因最新版本的下载可用就自动升级。对已校验解包目录执行: -> English: `third_party/` pins every upstream input of the plugin package, and the JDT LS release the tests run as -> the user's installation, by version, HTTPS URL and SHA-256. -> The prepare scripts download into the ignored `.artifacts/` directory and verify the checksum before use; no -> upstream binaries are committed. `backend/tests/repository_pins.rs` checks the pins. +```sh +node scripts/package/jdtls-runtime-profile.mjs .artifacts/jdtls --write +``` + +该命令只用于已审查的上游 pin 更新。正常 `prepare-jdtls.sh` 会比较而不会重写 profile。`backend/tests/repository_pins.rs` 检查 HTTPS、摘要格式、六平台覆盖、配置目录和 JDT LS 清单的一致性。上游来源和验证边界见 [运行环境说明](../docs/managed-runtimes.md)。 diff --git a/third_party/jdtls/runtime-files.json b/third_party/jdtls/runtime-files.json new file mode 100644 index 0000000..f6d65d3 --- /dev/null +++ b/third_party/jdtls/runtime-files.json @@ -0,0 +1,628 @@ +{ + "version": "1.61.0", + "archiveSHA256": "338e7e73d61836651ba2453919a0d34fa763eb4e7c03342092309bffb8934c64", + "files": [ + { + "path": "plugins/ch.qos.logback.classic_1.5.32.jar", + "size": 286451, + "sha256": "2d4cf592db78be2de4d6140434c2fec170dcb16a09e8c8b7b207dbf5e31b848a" + }, + { + "path": "plugins/ch.qos.logback.core_1.5.32.jar", + "size": 644407, + "sha256": "6a904d5778d0e361a9692f9cbe68b1b0620ae0f3eda2ec2ed09102755bf036c4" + }, + { + "path": "plugins/com.google.gson_2.14.0.jar", + "size": 313604, + "sha256": "2cbd119bf1961c28788310963dc80ba65f58cdeec1dd139c8bdb1240faa2c36f" + }, + { + "path": "plugins/com.google.guava.failureaccess_1.0.3.jar", + "size": 10763, + "sha256": "cbfc3906b19b8f55dd7cfd6dfe0aa4532e834250d7f080bd8d211a3e246b59cb" + }, + { + "path": "plugins/com.google.guava_33.6.0.jre.jar", + "size": 3064793, + "sha256": "dc573e1fca4fd5454f4a5fd3d7da2df03002876a4175bafc14a95980dd7713b3" + }, + { + "path": "plugins/com.sun.jna.platform_5.19.1.jar", + "size": 1416385, + "sha256": "3b3864f5b449e9c3c24b16861524b622b086563f44e0cd8384c8efc5a6052f82" + }, + { + "path": "plugins/com.sun.jna_5.19.1.v20260612-1000.jar", + "size": 1965688, + "sha256": "467b2990d4f406e7d41f7a989f89df257767ca11d566f844560e2ab8d09f6433" + }, + { + "path": "plugins/jakarta.annotation-api_1.3.5.jar", + "size": 25058, + "sha256": "85fb03fc054cdf4efca8efd9b6712bbb418e1ab98241c4539c8585bbc23e1b8a" + }, + { + "path": "plugins/jakarta.inject.jakarta.inject-api_1.0.5.jar", + "size": 10860, + "sha256": "a852b0971c589491e24334bd77e92760c048d2c102fc4c68e582e1cd53130f84" + }, + { + "path": "plugins/jakarta.servlet-api_6.1.0.jar", + "size": 398424, + "sha256": "8a31f465f3593bf2351531a5c952014eb839da96a605b5825b93dd54714c48c4" + }, + { + "path": "plugins/org.apache.ant_1.10.17.v20260410-1000.jar", + "size": 3441936, + "sha256": "c5c8e0d7665c9ffc9409ecb35d579d3901a6327aada2a3675c4b6486bf3c4fbf" + }, + { + "path": "plugins/org.apache.aries.spifly.dynamic.bundle_1.3.7.jar", + "size": 153960, + "sha256": "50446b18eaaa135d1927e283639a63e452c94111c28c2a54419b1b3fa0339afc" + }, + { + "path": "plugins/org.apache.commons.cli_1.11.0.jar", + "size": 110167, + "sha256": "8f7f8605d68e15bf32db61ec94eac6fdafc51b1bdbe1e0e0802b57d23f387792" + }, + { + "path": "plugins/org.apache.commons.commons-codec_1.20.0.jar", + "size": 401021, + "sha256": "6af66595f9f6a7bb58ce66518d6888d40b547c366d2262f06676eee19528ff66" + }, + { + "path": "plugins/org.apache.commons.lang3_3.20.0.jar", + "size": 713862, + "sha256": "69e5c9fa35da7a51a5fd2099dfe56a2d8d32cf233e2f6d770e796146440263f4" + }, + { + "path": "plugins/org.apache.felix.scr_2.2.18.jar", + "size": 409468, + "sha256": "c5bd887c8fd5ec4cd563249e7552bb1a1a1ca57e05a1f1ef8425a7b7b7bd2fbe" + }, + { + "path": "plugins/org.commonmark.ext-gfm-tables_0.30.0.jar", + "size": 24485, + "sha256": "5e28b48e66f7697bee4dfeb4c8f8f08a84a2827d91b53bbd9bd5445e82d14bda" + }, + { + "path": "plugins/org.commonmark_0.30.0.jar", + "size": 220139, + "sha256": "090f0a758ac2f4f51aa86dff9dff0fdf7403666d0efd29f59886dc8e8b1eac53" + }, + { + "path": "plugins/org.eclipse.ant.core_3.7.1000.v20260602-0655.jar", + "size": 105937, + "sha256": "136e7995f6b190f8d093f0ace382b9fd492bd04716f8c060d78fbf9c5e182394" + }, + { + "path": "plugins/org.eclipse.buildship.compat_3.1.12.v20260901-1217-s.jar", + "size": 19617, + "sha256": "a270a26382a346640c77eb3cf29a7fbb25fe5337268bac43022e7b38b023086e" + }, + { + "path": "plugins/org.eclipse.buildship.core_3.1.12.v20260901-1217-s.jar", + "size": 577034, + "sha256": "b2894c6b3e7d9778d8bf08c27391cc0448da62123de4769b0787072d1d1ab1aa" + }, + { + "path": "plugins/org.eclipse.compare.core_3.8.900.v20260731-0809.jar", + "size": 72886, + "sha256": "e75b07863128a076989d15e815d63a49cab772a338f1f0444d007bef3fa94601" + }, + { + "path": "plugins/org.eclipse.core.commands_3.13.0.v20260605-1749.jar", + "size": 121051, + "sha256": "fe916979793d364fcd0a71c15c3fa803d60a8566cff8c64b0eef04918b5b6a65" + }, + { + "path": "plugins/org.eclipse.core.contenttype_3.9.900.v20260617-0626.jar", + "size": 107781, + "sha256": "6c57132740523b5c5de125c0041ca43c1606da6563214c1bae3999fa21ead893" + }, + { + "path": "plugins/org.eclipse.core.expressions_3.9.700.v20260710-0925.jar", + "size": 99300, + "sha256": "06a18236ae181659e1e5499d912d68de527720686f1f51dab632d3e298e32b78" + }, + { + "path": "plugins/org.eclipse.core.filebuffers_3.8.600.v20260426-1223.jar", + "size": 122324, + "sha256": "1537b244abd74626b9627395c8562e910f68b6526330a7556f32d2a624b6e198" + }, + { + "path": "plugins/org.eclipse.core.filesystem_1.11.500.v20260721-1509.jar", + "size": 87415, + "sha256": "bf9ad56f6bee0044829bcbbe0ac5b9df28bb354beb0a4bdf0fe9a489ded12d36" + }, + { + "path": "plugins/org.eclipse.core.jobs_3.15.900.v20260604-0622.jar", + "size": 120947, + "sha256": "941b3c5feeba4ec0a949a8a94ff10283b2505813fa736c9e6345f146ae1b7e8a" + }, + { + "path": "plugins/org.eclipse.core.net_1.5.900.v20260507-0401.jar", + "size": 77837, + "sha256": "6e7a8db7d87a44bb35924bb345ddf0d9372413e3fee2edd842b50ed630ec254f" + }, + { + "path": "plugins/org.eclipse.core.resources_3.24.100.v20260812-0827.jar", + "size": 965528, + "sha256": "946851cf5902cd3b002920063a30b169e5710088b6c1ad7dd05bdd3be4fbfff4" + }, + { + "path": "plugins/org.eclipse.core.runtime_3.35.0.v20260623-1631.jar", + "size": 90388, + "sha256": "5b0c2794e9fe1785360dec920cc802f3388a0eb72ee25b89054b79ff3e2f07c9" + }, + { + "path": "plugins/org.eclipse.core.variables_3.6.900.v20260602-0702.jar", + "size": 40286, + "sha256": "553f09a59f2662fa4a3bbc94e84bd83221c1c6fb532d81b57010162fb47460a6" + }, + { + "path": "plugins/org.eclipse.debug.core_3.24.0.v20260714-0955.jar", + "size": 422465, + "sha256": "d145e39ee903c835c519b539fee28b5a02c6bdd6be3e084365023c8c6401b6c2" + }, + { + "path": "plugins/org.eclipse.equinox.app_1.7.600.v20251211-1038.jar", + "size": 93212, + "sha256": "fd353398835107608f554779a6e91891725efb94e0f57559d0ab3cea4b6156c7" + }, + { + "path": "plugins/org.eclipse.equinox.common_3.21.0.v20260604-1221.jar", + "size": 161122, + "sha256": "2545ed27d408f19882695703097e5998bf25652bd0dac76a8e6d1391ec228ab7" + }, + { + "path": "plugins/org.eclipse.equinox.frameworkadmin.equinox_1.3.400.v20250515-0513.jar", + "size": 75996, + "sha256": "5efab37c3d1de41fa4bba91d4b0fb682f03477f89a8616eae49e0768e2766663" + }, + { + "path": "plugins/org.eclipse.equinox.frameworkadmin_2.3.600.v20260306-0554.jar", + "size": 41506, + "sha256": "f2b956930b8383d708f1fe9df92938bffbe2e129082d4fd0b3d5f59c20a5c9f0" + }, + { + "path": "plugins/org.eclipse.equinox.launcher.cocoa.macosx.aarch64_1.2.1600.v20260804-1928.jar", + "size": 42707, + "sha256": "4a4d3a01c18e7634b6c0160250563f5ad5e189c2ebb913b50f890887b47c7f0e" + }, + { + "path": "plugins/org.eclipse.equinox.launcher.cocoa.macosx.x86_64_1.2.1600.v20260804-1928.jar", + "size": 42462, + "sha256": "ebb3d52cab339822ea4940b15d6ea6106b3f19b8f4e42f9123090ed36647a185" + }, + { + "path": "plugins/org.eclipse.equinox.launcher.gtk.linux.aarch64_1.2.1600.v20260804-1928.jar", + "size": 85703, + "sha256": "d40dfbab49fee84d55e3837e52be68c1315e13bdf261d7e0174b1270ba729c9f" + }, + { + "path": "plugins/org.eclipse.equinox.launcher.gtk.linux.x86_64_1.2.1600.v20260804-1928.jar", + "size": 84738, + "sha256": "3d74e756f0d78c8549d93264ad0f79812ab3077574b44eda3a1269873bfd4fa7" + }, + { + "path": "plugins/org.eclipse.equinox.launcher.win32.win32.x86_64_1.3.100.v20260804-1928.jar", + "size": 150597, + "sha256": "a8aae728f4b5f053a65b3ffa73d119ab9d1aa620f5b47f587e38f7ac6ef194f0" + }, + { + "path": "plugins/org.eclipse.equinox.launcher_1.8.0.v20260804-1928.jar", + "size": 52336, + "sha256": "9b3b1da60813ac5fa09dd5c198f1884be7076d0a5daec54faa3f351a787e34b7" + }, + { + "path": "plugins/org.eclipse.equinox.preferences_3.12.100.v20251111-0704.jar", + "size": 130382, + "sha256": "fd04e81a28ab32b6bb073286eb293c44b760176fcf1e35ef15614d62df820f86" + }, + { + "path": "plugins/org.eclipse.equinox.registry_3.12.600.v20250906-0651.jar", + "size": 206425, + "sha256": "4f8cd72681446b598390a8c24ee9b9996f6e4c5fabed022b50bd26f6f5a0bf6c" + }, + { + "path": "plugins/org.eclipse.equinox.security.linux_1.1.400.v20250521-0415.jar", + "size": 27064, + "sha256": "fd2fe77849feea313fcc8fb49c7114bd55f0e3cc5ec4bd6c0891d79d7a7a8b08" + }, + { + "path": "plugins/org.eclipse.equinox.security.macosx_1.102.500.v20250521-0414.jar", + "size": 31714, + "sha256": "a8408d4bcdc70e019d2d89ed8b1b0413eb74ea73e74fa3d064b7401643539797" + }, + { + "path": "plugins/org.eclipse.equinox.security.win32_1.3.0.v20240419-2334.jar", + "size": 15476, + "sha256": "cf9668c1d1e481059366abc2719468aa52e1276475cf9c32d4d10f57b34d7182" + }, + { + "path": "plugins/org.eclipse.equinox.security_1.4.700.v20250622-1644.jar", + "size": 120654, + "sha256": "91b74719f9c1a130193407808fe5daab3b92431efbf30b8f886f1ff5e97f468f" + }, + { + "path": "plugins/org.eclipse.equinox.simpleconfigurator.manipulator_2.3.700.v20260306-0556.jar", + "size": 31055, + "sha256": "1a24a3c0fb01ad71f97432d5c2b364d9868b5a5ebd99a1308aacb1a2c03c47da" + }, + { + "path": "plugins/org.eclipse.equinox.simpleconfigurator_1.5.700.v20251111-1031.jar", + "size": 57247, + "sha256": "d250938d3715529a9822fcdf46ad2f5de39720558d7195b5c1a8713af00bcd13" + }, + { + "path": "plugins/org.eclipse.jdt.apt.core_3.8.800.v20260608-1927.jar", + "size": 411079, + "sha256": "f3f15b70f1ec21ca0cd8ecebdb09f2345894508216a9cb733c939d9582c87a3d" + }, + { + "path": "plugins/org.eclipse.jdt.apt.pluggable.core_1.4.700.v20251202-0459.jar", + "size": 43117, + "sha256": "1bde3ae8f333266497c999e5160cc3a7ea8951a10d5191bf60dcda2c942242de" + }, + { + "path": "plugins/org.eclipse.jdt.core.compiler.batch_3.46.100.v20260826-1225.jar", + "size": 3384534, + "sha256": "74c93172475fee0cd4e6eefb44233516dd40525642da35d009146d97ea598229" + }, + { + "path": "plugins/org.eclipse.jdt.core.javac_1.0.0.z20260430-1959.jar", + "size": 873145, + "sha256": "a6d0f8fabd64c248c37c463789a1a13f801252b68b0a4f4808c207677b5cae17" + }, + { + "path": "plugins/org.eclipse.jdt.core.manipulation_1.25.0.v20260813-1704.jar", + "size": 4926955, + "sha256": "dadd2bae4f2d9b8eeda92161edd146878e866d6555591dfe0e3309670d5fcd48" + }, + { + "path": "plugins/org.eclipse.jdt.core_3.47.0.v20260828-1141.jar", + "size": 4521231, + "sha256": "723e30be1e841516c388ebb32017cb8b36662808f46be5265b78cc06bd4fe71c" + }, + { + "path": "plugins/org.eclipse.jdt.debug_3.26.100.v20260714-1432.jar", + "size": 964671, + "sha256": "585fe0f754e8b364258abfb5733e65bf1da895b9c5d628d577e7cf7e6a421915" + }, + { + "path": "plugins/org.eclipse.jdt.junit.core_3.15.0.v20260713-1834.jar", + "size": 195351, + "sha256": "8767b333df9c8dbdc7d5302c0bd9e8c2c7eb7ed1add433f6003bf63095e88675" + }, + { + "path": "plugins/org.eclipse.jdt.junit.runtime_3.8.100.v20260507-0922.jar", + "size": 64703, + "sha256": "40f42db018f283e8e799333c1870d8a6ee14691a591927c77419373a1dd0d3a9" + }, + { + "path": "plugins/org.eclipse.jdt.launching_3.24.300.v20260609-0435.jar", + "size": 619373, + "sha256": "d8aad606c07b42a189a353797d9b3d1493f794647128bbad17908b0d58ba95e0" + }, + { + "path": "plugins/org.eclipse.jdt.ls.core_1.61.0.202609031315.jar", + "size": 1816623, + "sha256": "b382afc38a89e41959a56aee532ae567c7f804c3e4d4f13444114468789ec032" + }, + { + "path": "plugins/org.eclipse.jdt.ls.filesystem_1.61.0.202609031315.jar", + "size": 23814, + "sha256": "e6775fb4c4ab58cfc8441040b741d4718f24614b3c6e05e941f1b68ebfa88f1f" + }, + { + "path": "plugins/org.eclipse.jdt.ls.logback.appender_1.61.0.202609031315.jar", + "size": 17150, + "sha256": "3584cc8e64079a7dbcb9260f6005535e1b74e323c92ac0c9bf0e2dd3ca3a0fda" + }, + { + "path": "plugins/org.eclipse.lsp4j.jsonrpc_1.0.0.v20260209-1721.jar", + "size": 155511, + "sha256": "9647feb0524bf763c878e12ab878a684102b81cccb3f77feecbec709d54f9bbb" + }, + { + "path": "plugins/org.eclipse.lsp4j_1.0.0.v20260209-1721.jar", + "size": 684229, + "sha256": "ccd78893facc6bfcc359d56cba05d3d5b85eb41e4c40d4b4215ca45db5f416d9" + }, + { + "path": "plugins/org.eclipse.ltk.core.refactoring_3.16.0.v20260702-0744.jar", + "size": 381852, + "sha256": "fc185dee6c34e594297471ab72f25c1e76deef6dbf674d3c2f0deee3b73e5b7f" + }, + { + "path": "plugins/org.eclipse.m2e.apt.core_2.3.100.20250418-1315.jar", + "size": 56663, + "sha256": "768aab803fc90eff25130aaf583aeb8791f7a8e55a9c3cadba305b95c70032f9" + }, + { + "path": "plugins/org.eclipse.m2e.core_2.7.800.20260522-0510.jar", + "size": 630252, + "sha256": "966345e9c87fd50adacb2785ff9486e851bdcaea02a089215a18bca956e33382" + }, + { + "path": "plugins/org.eclipse.m2e.jdt_2.5.200.20260602-0749.jar", + "size": 175144, + "sha256": "24532a0dac7cd7cc44dedb21ad6b687b33787fc9eddf708476491a3fe86d9275" + }, + { + "path": "plugins/org.eclipse.m2e.maven.runtime_3.9.1600.20260522-0510.jar", + "size": 5958733, + "sha256": "2aaf8786ecf333a5f8f910bac6e4ae04b243d5dcb811eb4aa79585b9fd4263c7" + }, + { + "path": "plugins/org.eclipse.m2e.workspace.cli_0.4.0.jar", + "size": 17901, + "sha256": "53376fa2d7bfd2d5166806e74af9576ee3f8f1c1ac916e2cb4d2bb0c3e72c02f" + }, + { + "path": "plugins/org.eclipse.osgi.compatibility.state_1.3.0.v20251022-1724.jar", + "size": 260438, + "sha256": "94c1f866af37588c50ed3e95ed6f03eae6e1d81f111cba100d503fef23186028" + }, + { + "path": "plugins/org.eclipse.osgi_3.24.300.v20260721-1251.jar", + "size": 1615320, + "sha256": "4a770aa4a78df653af871073c8b4ddd56884895f5fc71d10c40b4289ac7c8b9f" + }, + { + "path": "plugins/org.eclipse.search.core_3.16.700.v20260505-0615.jar", + "size": 62763, + "sha256": "daa86749c223226d64d47f1574be7c88580e27da4d562e0160cf44bfa569e843" + }, + { + "path": "plugins/org.eclipse.text_3.14.800.v20260815-0849.jar", + "size": 363930, + "sha256": "14814c1f1a737fde0a2d56c47a2f02cf4c8c5dee748756c4763e674cae214250" + }, + { + "path": "plugins/org.eclipse.xtext.xbase.lib_2.42.0.v20260223-0608.jar", + "size": 170351, + "sha256": "8cafdec5bb97a53c93b3b378e056a4d1acefb6f6baebd89c58c6e9794dcce89f" + }, + { + "path": "plugins/org.gradle.toolingapi_8.9.0.v20260901-1217-s.jar", + "size": 3302722, + "sha256": "124d1147714d9b70bab136479b4501b6906ca43321b39d4bbf626d6c73d99fc1" + }, + { + "path": "plugins/org.hamcrest_3.0.0.jar", + "size": 126373, + "sha256": "5d66b6a4a680755cb6ed7cb104fa7835ef644667586ff0737adeb977c39ecdbc" + }, + { + "path": "plugins/org.jsoup_1.19.1.jar", + "size": 472999, + "sha256": "7b850eb00f2f77f606a343b2e4effe4107f3c1faa183729d85fbe16baf606096" + }, + { + "path": "plugins/org.junit_4.13.2.v20240929-1000.jar", + "size": 426304, + "sha256": "62f9c996330614c3fce34abf18f4226b11b1ef646ba735cb1089b463a5ba15af" + }, + { + "path": "plugins/org.objectweb.asm.commons_9.10.1.jar", + "size": 74840, + "sha256": "6d0abefb7cbf972ea16edb37ec14835372505063a45f976ab7ea889ed9497895" + }, + { + "path": "plugins/org.objectweb.asm.tree.analysis_9.10.1.jar", + "size": 35140, + "sha256": "dede75a21306b65974ecd8f87114ff6970f09fb794157a4ca09ab25c888c2bfc" + }, + { + "path": "plugins/org.objectweb.asm.tree_9.10.1.jar", + "size": 51958, + "sha256": "3dfb0d5b6a106cd40b5b250e39935fbf2f927f4477546a5369a3ac609cf0506b" + }, + { + "path": "plugins/org.objectweb.asm.util_9.10.1.jar", + "size": 95628, + "sha256": "1bb99d091fba2597dc6d51193e9bbcf0d8447e7ed96bd8f0198b18152f09655c" + }, + { + "path": "plugins/org.objectweb.asm_9.10.1.jar", + "size": 126151, + "sha256": "ed825d10ab1399c8c0cb669e688cf0c8c82629b4c8399b58352b68e92ca10fcb" + }, + { + "path": "plugins/org.osgi.service.component_1.5.1.202212101352.jar", + "size": 66447, + "sha256": "0653852deab5c6f6e9c84e3aa8f72e72b9ce7dfaf7a6431f3d80f6f9d7a433ad" + }, + { + "path": "plugins/org.osgi.service.prefs_1.1.2.202109301733.jar", + "size": 20165, + "sha256": "43c7c870710e363405d422da653cce0d798a4537f76e4930f79bceadd3a55345" + }, + { + "path": "plugins/org.osgi.util.function_1.2.0.202109301733.jar", + "size": 23641, + "sha256": "208819c7c71690c15a6bb8b187474e7f9d0147946b680182a62b9f222ae014ec" + }, + { + "path": "plugins/org.osgi.util.promise_1.3.0.202212101352.jar", + "size": 85659, + "sha256": "7053c57e7d7d88fec6b90979a3af125e1d2bb847268a328a2f1ed65ad0a4c185" + }, + { + "path": "plugins/slf4j.api_2.0.18.jar", + "size": 69982, + "sha256": "44508fd1576500688c790b190acdd16fec4f8c79a3e0b900afd70503cf055f55" + }, + { + "path": "plugins/wrapped.com.jetbrains.intellij.java.java-decompiler-engine_253.29346.240.jar", + "size": 940444, + "sha256": "1a0e48220efd35b458cb1ec90fc0044022c573ce8182fda5fcb0c55206d5b8ce" + }, + { + "path": "plugins/wrapped.com.vladsch.flexmark.flexmark-ext-emoji_0.64.8.jar", + "size": 98641, + "sha256": "1135ca3863018fc03f98a5c656e8e4540d5442f067d10586c603876ab0095e3b" + }, + { + "path": "plugins/wrapped.com.vladsch.flexmark.flexmark-ext-gfm-strikethrough_0.64.8.jar", + "size": 24325, + "sha256": "c622f360096204a63578b7350705991c7c030ab2ae5f2f9642b1821c358c7aaa" + }, + { + "path": "plugins/wrapped.com.vladsch.flexmark.flexmark-ext-ins_0.64.8.jar", + "size": 12453, + "sha256": "d7b50c0e7d117a9c0c802d6bf2ad5a1e127af280f294bdcb29e4b15e31bc7d6f" + }, + { + "path": "plugins/wrapped.com.vladsch.flexmark.flexmark-ext-superscript_0.64.8.jar", + "size": 12938, + "sha256": "dabef0631e2379654dd354cf61a4b8e8196f6a28009c41df5441352ecb1e2d9a" + }, + { + "path": "plugins/wrapped.com.vladsch.flexmark.flexmark-ext-tables_0.64.8.jar", + "size": 48708, + "sha256": "ebc3452c61ae24fdbb7f7828a1aa84c0ac7807ab455dcaa361db766e53dcea52" + }, + { + "path": "plugins/wrapped.com.vladsch.flexmark.flexmark-ext-wikilink_0.64.8.jar", + "size": 31081, + "sha256": "705a338bc9e9bf61f96fb72a6b12a70ecc95a84cb9e367cd302acf3bbd50fded" + }, + { + "path": "plugins/wrapped.com.vladsch.flexmark.flexmark-html2md-converter_0.64.8.jar", + "size": 82996, + "sha256": "12d881a35b2ff8ed930c24108eacdae8649bb8226d3cf9b9003193d2ba0101ed" + }, + { + "path": "plugins/wrapped.com.vladsch.flexmark.flexmark-jira-converter_0.64.8.jar", + "size": 12876, + "sha256": "de2e993095d26d01d622edf49c564d1ac650ba64c4df46f74dbd4c4df8a91100" + }, + { + "path": "plugins/wrapped.com.vladsch.flexmark.flexmark-util-ast_0.64.8.jar", + "size": 67308, + "sha256": "03cb9aa7f4a26583fa908d804e874e6bec119f5a38cde93ceaccdc033b54a7a8" + }, + { + "path": "plugins/wrapped.com.vladsch.flexmark.flexmark-util-builder_0.64.8.jar", + "size": 5788, + "sha256": "3200a8e776a16987fcacf58ac1e6f867feb71b19ddc8e5a47c58b567791afb2e" + }, + { + "path": "plugins/wrapped.com.vladsch.flexmark.flexmark-util-collection_0.64.8.jar", + "size": 68044, + "sha256": "1688dd9fe10bbd74a00530fd7bb080be90762444d970ddff99d670423f9b476f" + }, + { + "path": "plugins/wrapped.com.vladsch.flexmark.flexmark-util-data_0.64.8.jar", + "size": 25964, + "sha256": "beb7a5b1ff99361bd3081fcc8f5399b3ad44c2e22e60318c14a5310cd169a07f" + }, + { + "path": "plugins/wrapped.com.vladsch.flexmark.flexmark-util-dependency_0.64.8.jar", + "size": 17131, + "sha256": "b248aa574c39ea1fcdcc58bb02dfee9c835eccbfc336cf1472de7a4d3d969de8" + }, + { + "path": "plugins/wrapped.com.vladsch.flexmark.flexmark-util-format_0.64.8.jar", + "size": 111484, + "sha256": "3a926be1a7788d03b4fdfd85788ee76ff62246d48349efef1983f13412c1b1c9" + }, + { + "path": "plugins/wrapped.com.vladsch.flexmark.flexmark-util-html_0.64.8.jar", + "size": 45423, + "sha256": "a08d0a77f98e0baab8a1f0de6933af614b08f2c82f508990a061a4b122050a3c" + }, + { + "path": "plugins/wrapped.com.vladsch.flexmark.flexmark-util-misc_0.64.8.jar", + "size": 60547, + "sha256": "65f8139f44d03243e8d53d81d739e9cacff609c6d423002af8bd5eec241577e0" + }, + { + "path": "plugins/wrapped.com.vladsch.flexmark.flexmark-util-options_0.64.8.jar", + "size": 12498, + "sha256": "8d46c7d570aded9e775598a3eba244ea2035a2fa64d106a4d6e30cb990bf1a63" + }, + { + "path": "plugins/wrapped.com.vladsch.flexmark.flexmark-util-sequence_0.64.8.jar", + "size": 239124, + "sha256": "d94b8d5c14868d1b54d4e5e1c15ceab25ad5f34df0e7593d9b56f54caa979e07" + }, + { + "path": "plugins/wrapped.com.vladsch.flexmark.flexmark-util-visitor_0.64.8.jar", + "size": 7278, + "sha256": "fe02f0a6b4f0334f5d061c0b2d232c6135f262c4b0e886a937f5605a436518ba" + }, + { + "path": "plugins/wrapped.com.vladsch.flexmark.flexmark-util_0.64.8.jar", + "size": 2154, + "sha256": "345ed4a20006d18abaaface894deb75e915cf9b1ba4530cf2e9a0026775bebcb" + }, + { + "path": "plugins/wrapped.com.vladsch.flexmark.flexmark_0.64.8.jar", + "size": 451880, + "sha256": "cdde0d2dd5e9965b023fa246cd5ce5240fe5fc578832968dbefefb43d13c2f3e" + }, + { + "path": "plugins/wrapped.org.jetbrains.annotations_24.0.1.jar", + "size": 32570, + "sha256": "3e8e96e43b456d01d7ee08e8c043e6efbceb438a13e774d3b1dbc13941d3a24a" + } + ], + "configurations": { + "config_linux": { + "path": "config_linux/config.ini", + "size": 7946, + "sha256": "0591b9ca41a83b3d9fa4bcb36c83361bb287a63438fe665292e758bdc3e536a7" + }, + "config_linux_arm": { + "path": "config_linux_arm/config.ini", + "size": 7947, + "sha256": "f3a00e56f5cb7b974e4eaf7215ec27a470b82f497ee5ea40297372fc4785cf8b" + }, + "config_mac": { + "path": "config_mac/config.ini", + "size": 7952, + "sha256": "6334ec5dc504c99e8fa4a0eb1782afef5a80d905a89f47dd65227d30c6c04247" + }, + "config_mac_arm": { + "path": "config_mac_arm/config.ini", + "size": 7953, + "sha256": "41807bb9e8b31fa3585b50f93c22b4b358611b4f31490954d085161f9f95535c" + }, + "config_ss_linux": { + "path": "config_ss_linux/config.ini", + "size": 5838, + "sha256": "471f61b9dd9c42ba024a29c229d91ea637e969102f83620c5a8aa55c38615a5c" + }, + "config_ss_linux_arm": { + "path": "config_ss_linux_arm/config.ini", + "size": 5839, + "sha256": "5ecd0eafb38ddc94d450ab6792d76f66003f8f3a928ade76d20e91190cf3f53d" + }, + "config_ss_mac": { + "path": "config_ss_mac/config.ini", + "size": 5844, + "sha256": "708839d7439faa9b1f5ef38fd66977aca86aa2f7b800d98347982a6be2d849b4" + }, + "config_ss_mac_arm": { + "path": "config_ss_mac_arm/config.ini", + "size": 5845, + "sha256": "ac398337717b675788a2d5a962cde9cd4fd57550542471a2bf1f3cf87eb6a626" + }, + "config_ss_win": { + "path": "config_ss_win/config.ini", + "size": 5837, + "sha256": "217080b4d8d9dbe14f006244d28164485887cd1aeaa8a8e80e42ad92af4c6c3d" + }, + "config_win": { + "path": "config_win/config.ini", + "size": 7945, + "sha256": "da95ae9aa8a8c493acef1a561db053a93c2ee99c0d4bfb9c5534a4031c82b098" + } + } +}