Skip to content

在 AUTO 模式下补充 Java 版本告警,并记住用户接受的选择(#6799) - #6801

Open
Chen-Mengze wants to merge 14 commits into
HMCL-dev:mainfrom
Chen-Mengze:main
Open

在 AUTO 模式下补充 Java 版本告警,并记住用户接受的选择(#6799)#6801
Chen-Mengze wants to merge 14 commits into
HMCL-dev:mainfrom
Chen-Mengze:main

Conversation

@Chen-Mengze

Copy link
Copy Markdown

概述

针对 #6799,在 AUTO 模式下补充 Java 版本告警,并在用户接受风险后按实例记住选择,仅在因此崩溃时重新提醒。

主要修改

1. 新增诊断组件(HMCLCore,纯函数,与选 Java 完全解耦)

  • JavaCompatibility:诊断结果 record(targetMajor / actualMajor / Level)。
  • JavaCompatibilityEvaluator纯函数,无 IO、无 UI、无设置访问。仅由 LauncherHelper 在拿到 Java 后调用,"找 Java" 与 "要不要问用户" 两件事彻底分离,未改动 JavaManagerJavaVersionConstraint

2. 目标版本取自 Mojang 官方声明,不再硬编码区间

manifest.javaVersion() 是 version.json 自带的权威要求,MC 出新版本时零改动生效。

上界 = 目标版本 + 容忍档位,按 ModLoaderType 以数据表配置(新增加载器 = 加 1 行,调优 = 改 1 个数字),不再是 MODDED_JAVA_* 那种写死的三段字面量区间。

3. LauncherHelper AUTO 分支接入

仅在 JavaVersionType.AUTO 下校验——HMCL 自己做决策时才有义务告知;手动指定的用户已知情,不打扰。

命中时弹窗,提供一键修正:已装对应版本则直接切换,否则复用 downloadJava 下载。修正动作不调用 setJavaAutoSelected(),避免把用户踢回 AUTO 后警告永久消失。

4. 实例级记住,崩溃时重新武装

点「否」后按 actualMajor:expectedMajor 写入实例级设置(组合变化即重新提醒,避免一次性静默到永远)。

崩溃撤回复用 CrashReportAnalyzer 现有规则(JAVA_VERSION_IS_TOO_HIGHJDK_9NEED_JDK11MODLAUNCHER_8TOO_OLD_JAVAMAC_JDK_8U261),不新增正则、不重复造轮子。与 Java 无关的崩溃保持静默,不做无谓打扰。

5. 翻译

launch.advice.switch_java 新增 10 语;解释部分复用已有的 launch.advice.modded_java(上游已译 9 语),并补上日语缺失的该条目。

设计取舍

  • 建议级而非强制:是否崩溃取决于具体 mod 组合,无法静态判定,因此只提示不拦截。
  • 存组合而非布尔:只存"已忽略"会让 Java 从 25 升到 29 这类新风险也被永久静默。
  • 崩溃即撤回而非匹配崩溃特征:判定交给 CrashReportAnalyzer,规则由上游维护,新增特征自动生效。

测试

1.20.1 Forge + 仅 Java 25 → 期望 17、Forge 容忍 1 档(上限 21),25 > 21 → 触发提示。

  • 点「是」:切换到/下载 Java 17
  • 点「否」:写入 25:17,后续启动不再弹
  • Unsupported class file major version 崩溃:下次重新提醒
  • 因 mod 冲突崩溃:保持静默

@github-actions github-actions Bot added the 100+ label Sep 1, 2026

@github-actions github-actions Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🤖 Static analysis found the following issues (max count 10):

Comment thread HMCL/src/main/java/org/jackhuang/hmcl/game/LauncherHelper.java Outdated
Comment thread HMCL/src/main/java/org/jackhuang/hmcl/game/LauncherHelper.java
Comment thread HMCL/src/main/java/org/jackhuang/hmcl/game/LauncherHelper.java Outdated
Comment thread HMCL/src/main/java/org/jackhuang/hmcl/game/LauncherHelper.java
Comment thread HMCL/src/main/java/org/jackhuang/hmcl/game/LauncherHelper.java
Comment thread HMCL/src/main/java/org/jackhuang/hmcl/game/LauncherHelper.java

@github-actions github-actions Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🤖 Static analysis found the following issues (max count 10):

Comment thread HMCL/src/main/java/org/jackhuang/hmcl/game/LauncherHelper.java Outdated
Comment thread HMCL/src/main/java/org/jackhuang/hmcl/game/LauncherHelper.java
Comment thread HMCL/src/main/java/org/jackhuang/hmcl/game/LauncherHelper.java Outdated
Comment thread HMCL/src/main/java/org/jackhuang/hmcl/game/LauncherHelper.java
Comment thread HMCL/src/main/java/org/jackhuang/hmcl/game/LauncherHelper.java
Comment thread HMCL/src/main/java/org/jackhuang/hmcl/game/LauncherHelper.java
@Glavo

Glavo commented Sep 2, 2026

Copy link
Copy Markdown
Member

@codex review

@chatgpt-codex-connector

chatgpt-codex-connector Bot commented Sep 2, 2026

Copy link
Copy Markdown

Codex Review Summary

This comment shows the latest Codex review activity on this pull request.

Review Status Commit Review trigger
📝 Code Review Completed 2026-09-02T12:34:50.621904Z 18630e5 Manual request
ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review" or "@codex security review".

Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings.

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 18630e5ae7

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment thread HMCL/src/main/java/org/jackhuang/hmcl/game/LauncherHelper.java Outdated
Comment thread HMCL/src/main/java/org/jackhuang/hmcl/game/LauncherHelper.java
Comment thread HMCL/src/main/java/org/jackhuang/hmcl/game/LauncherHelper.java Outdated
平台不支持时保留当前 Java 继续启动,不取消。
Join 之后再把 FX 队列 flush 掉(runLater 是 FIFO,插一个 latch 并 await 即可),顺便给 logs 的读取加锁。
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants