Skip to content

Conversation

@Glavo
Copy link
Member

@Glavo Glavo commented Oct 25, 2025

之前我们依靠读取 release 文件加速读取 Java 信息。但是 release 文件包含的信息较少,而且我们无法从 release 文件中得知该 Java 是否能正常工作,所以可能会造成游戏无法启动的问题。

本 PR 调整了读取 Java 信息的机制,现在 HMCL 总是通过运行 Java 来获取信息。为了降低开销,我们现在使用一个缓存文件来缓存读取到的 Java 信息。

Copilot AI review requested due to automatic review settings October 25, 2025 08:39
Copy link
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 refactors Java detection and information retrieval to improve reliability by always running Java executables to obtain version information, rather than relying on potentially incomplete release files. To minimize performance overhead, a caching mechanism is introduced that stores Java information in a cache file (javaCache.json).

Key changes:

  • Introduced caching system for Java information with version-aware cache file management
  • Refactored Java search logic into a dedicated Searcher class
  • Modified JavaRepository interface to return Collection<Path> instead of Collection<JavaRuntime>

Reviewed Changes

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

Show a summary per file
File Description
HMCLCore/src/main/java/org/jackhuang/hmcl/java/JavaRepository.java Changed return type of getAllJava() from Collection<JavaRuntime> to Collection<Path>
HMCLCore/src/main/java/org/jackhuang/hmcl/java/JavaInfo.java Added Builder pattern, removed release file parsing, modernized vendor normalization switch statement
HMCL/src/main/java/org/jackhuang/hmcl/java/JavaManager.java Implemented cache-based Java search with dedicated Searcher class, added cache key generation and validation logic
HMCL/src/main/java/org/jackhuang/hmcl/java/JavaInfoUtils.java Removed release file parsing, simplified to always execute Java for information retrieval
HMCL/src/main/java/org/jackhuang/hmcl/java/HMCLJavaRepository.java Updated to return paths instead of runtime objects, simplified platform-specific logic

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

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.

1 participant