Skip to content

将 OS X 重命名为 macOS#3878

Merged
Glavo merged 22 commits intoHMCL-dev:mainfrom
Glavo:osx-macos
May 20, 2025
Merged

将 OS X 重命名为 macOS#3878
Glavo merged 22 commits intoHMCL-dev:mainfrom
Glavo:osx-macos

Conversation

@Glavo
Copy link
Copy Markdown
Member

@Glavo Glavo commented Apr 30, 2025

2016 年苹果已经将 OS X 重命名为 macOS,至今已经有近十年历史。

现在大多数场景都在使用 macOS 这个名称,除了 OSRestrictionLibrary,没有地方应该用 OS X 这个名称,我们应当重命名它来符合新的规范。

@Pigeon0v0
Copy link
Copy Markdown
Contributor

我记得部分用户界面的显示文本貌似是 MacOS,如果有这个情况,是否应该修正大小写?

@Glavo
Copy link
Copy Markdown
Member Author

Glavo commented Apr 30, 2025

我记得部分用户界面的显示文本貌似是 MacOS,如果有这个情况,是否应该修正大小写?

目前 HMCL 中没有地方使用 MacOS

@Glavo Glavo requested a review from Copilot May 10, 2025 03:15
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull Request Overview

This pull request renames all occurrences of "OS X" to "macOS" in order to align with current naming conventions. Key changes include renaming constants and keys in Java code and resource files, updating property files and shell scripts, and refactoring helper methods to support the new naming.

Reviewed Changes

Copilot reviewed 30 out of 30 changed files in this pull request and generated no comments.

Show a summary per file
File Description
HMCLCore/src/main/java/org/jackhuang/hmcl/game/Library.java Changed the natives map key type and updated key lookup from OperatingSystem to a string based on Mojang's naming.
HMCLCore/src/main/java/org/jackhuang/hmcl/game/JavaVersionConstraint.java Updated OS name checks from OSX to MACOS.
HMCLCore/src/main/java/org/jackhuang/hmcl/game/GameJavaVersion.java Replaced case OSX with MACOS in version handling.
HMCLCore/src/main/java/org/jackhuang/hmcl/download/java/disco/DiscoJavaDistribution.java Updated enum pairs from OSX to MACOS.
HMCLCore/src/main/java/org/jackhuang/hmcl/download/java/disco/DiscoFetchJavaListTask.java Eliminated helper methods and used updated OperatingSystem names.
Resource Files & Shell Script Updated JSON keys and property files, and changed OS values in HMCLauncher.sh.
Various UI and utility classes Replaced OperatingSystem.OSX constants with OperatingSystem.MACOS in dialogs, executables, and method calls.
HMCL/src/main/java/org/jackhuang/hmcl/java/HMCLJavaRepository.java Refactored getAllJava method for handling MACOS differently.
HMCL/src/main/java/org/jackhuang/hmcl/Main.java and Launcher.java Updated OS checks from OSX to MACOS.
Comments suppressed due to low confidence (1)

HMCL/src/main/java/org/jackhuang/hmcl/java/HMCLJavaRepository.java:146

  • The variable 'root' is undefined in this scope; consider replacing it with 'platformRoot', which is already defined, to ensure the code compiles correctly.
platformRoot = root.resolve(platform.getOperatingSystem().getMojangName() + "-" + platform.getArchitecture().getCheckedName());

@burningtnt
Copy link
Copy Markdown
Member

反对在技术层面将 OS X 更名为 macOS。

目前,HMCL 在内部有数处对 OperatingSystem 的序列化 / 反序列化操作。这种技术更名并不能带来任何优势,反而可能导致潜在的 Bug。

如果仅仅是在 UI 层面做更名,这是可行的。但在代码层面直接更名 OperatingSystem 的枚举值着实欠考虑了。

@Glavo
Copy link
Copy Markdown
Member Author

Glavo commented May 11, 2025

目前,HMCL 在内部有数处对 OperatingSystem 的序列化 / 反序列化操作。这种技术更名并不能带来任何优势,反而可能导致潜在的 Bug。

OperatingSystem 直接进行序列化/反序列化是存在问题的,比如 HMCL 下载的版本 JSON 中 universal 会被错误地记录为 unknown 就是对 OperatingSystem 序列化和反序列化造成的。

更新这些这些位置是计划中的一部分,本 PR 的目的之一就是让这些问题暴露出来,解决这些隐患,增强代码的稳健性。

@burningtnt
Copy link
Copy Markdown
Member

目前,HMCL 在内部有数处对 OperatingSystem 的序列化 / 反序列化操作。这种技术更名并不能带来任何优势,反而可能导致潜在的 Bug。

OperatingSystem 直接进行序列化/反序列化是存在问题的,比如 HMCL 下载的版本 JSON 中 universal 会被错误地记录为 unknown 就是对 OperatingSystem 序列化和反序列化造成的。

更新这些这些位置是计划中的一部分,本 PR 的目的之一就是让这些问题暴露出来,解决这些隐患,增强代码的稳健性。

你所提到的问题已经在 #3547 中将对应问题修复。直接更名会导致日后不少版本都可能出现序列化 / 反序列化问题,不利于启动器的稳定。

我提议仅在 I18N 等语言文件中更名 OS X 到 macOS,而非直接进行破坏性更改。

@Glavo
Copy link
Copy Markdown
Member Author

Glavo commented May 11, 2025

直接更名会导致日后不少版本都可能出现序列化 / 反序列化问题,不利于启动器的稳定。

为了稳定性,这些代码本就不该和枚举变量的名称耦合。尤其是 macOS,它具有多个序列化名称,mac-osmacososx 同时在 HMCL 代码中使用,使 OS X 作为默认名称存在很高的滥用风险。

本 PR 已经审查并更新了 OperatingSystem 的所有用例,如果还有遗漏之处应当视为错误处理,通过序列化/反序列化问题暴露出来是预期中的正确行为。由于 osx 这个序列化名称只有极个别地方在使用,出现问题的风险也不算高。

只更新 i18n 无法暴露这些隐患,无法起到预期的作用。

@Glavo Glavo requested a review from Copilot May 20, 2025 05:52
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull Request Overview

This PR renames all occurrences of “OS X” to “macOS” across code, scripts, and resource files to align with Apple’s current naming convention.

  • Updated code references from OperatingSystem.OSX to OperatingSystem.MACOS
  • Renamed JSON and shell script keys from “osx” to “macos”
  • Updated i18n property keys and lookup to use “macos_arm64”

Reviewed Changes

Copilot reviewed 30 out of 30 changed files in this pull request and generated 1 comment.

Show a summary per file
File Description
Library.java Changed natives map key type from OperatingSystem to String and lookup to use getMojangName()
JavaVersionConstraint.java Replaced OS X enum check with MACOS
GameJavaVersion.java Switched case labels from OSX to MACOS
DiscoJavaDistribution.java Updated enum entries from OSX to MACOS
DiscoFetchJavaListTask.java Removed helper, now using getCheckedName() directly
openjfx-dependencies.json Renamed “osx-” arrays to “macos-
natives.json Renamed “osx-arm64” key to “macos-arm64”
I18N_*.properties (zh, zh_CN, ru, es, default) Renamed i18n key fatal.unsupported_platform.osx_arm64 to macos_arm64
HMCLauncher.sh Changed _HMCL_OS assignment and download page cases to “macos”
NativePatcher.java Updated OSX checks to MACOS
FXUtils.java Replaced OSX references with MACOS
Controllers.java Updated dialog key and enum check from OSX to MACOS
JavaManager.java Switched platform checks and case label from OSX to MACOS
HMCLJavaRepository.java Updated OSX checks to MACOS and refactored getAllJava
Main.java Changed icon init condition from OSX to MACOS
Launcher.java Replaced SDK translocation checks from OSX to MACOS
Comments suppressed due to low confidence (6)

HMCL/src/main/resources/assets/lang/I18N_zh_CN.properties:393

  • The property key changed from fatal.unsupported_platform.osx_arm64 to fatal.unsupported_platform.macos_arm64. Confirm that all code references (e.g., in Controllers.java) were updated to match this new key.
fatal.unsupported_platform.macos_arm64=Hello Minecraft! Launcher 已为 Apple Silicon 平台提供支持...

HMCLCore/src/main/java/org/jackhuang/hmcl/game/Library.java:97

  • This lookup assumes that the natives map is populated using getMojangName(). Ensure that map construction was updated to use the same keys, or this lookup will always fail.
if (natives != null && natives.containsKey(OperatingSystem.CURRENT_OS.getMojangName()))

HMCLCore/src/main/java/org/jackhuang/hmcl/download/java/disco/DiscoFetchJavaListTask.java:49

  • Verify that getCheckedName() returns "macos" for OperatingSystem.MACOS, matching the Disco API expectation.
params.put("operating_system", platform.getOperatingSystem().getCheckedName());

HMCL/src/main/resources/assets/openjfx-dependencies.json:80

  • You renamed the key from osx-x86_64 to macos-x86_64. Ensure that the loader reading this JSON also expects the new key, otherwise these entries will no longer be picked up.
"macos-x86_64": [

HMCL/src/main/java/org/jackhuang/hmcl/java/JavaManager.java:77

  • In getMojangJavaPlatform, the MACOS branch returns the literal "mac-os". Ensure that this hyphenated form is intentional and matches downstream expectations.
else if (platform.getOperatingSystem() == OperatingSystem.MACOS) {

HMCL/src/main/resources/assets/HMCLauncher.sh:17

  • You updated _HMCL_OS to macos here but other parts of the script may still reference osx. Run a global search to ensure consistency throughout the shell script.
_HMCL_OS="macos";;

@Glavo Glavo merged commit 48e3f79 into HMCL-dev:main May 20, 2025
3 checks passed
@Glavo Glavo deleted the osx-macos branch May 20, 2025 11:34
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants