-
Notifications
You must be signed in to change notification settings - Fork 778
搜索 Java 时缓存 Java 信息 #4716
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
搜索 Java 时缓存 Java 信息 #4716
Conversation
There was a problem hiding this 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
Searcherclass - Modified
JavaRepositoryinterface to returnCollection<Path>instead ofCollection<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.
之前我们依靠读取
release文件加速读取 Java 信息。但是release文件包含的信息较少,而且我们无法从release文件中得知该 Java 是否能正常工作,所以可能会造成游戏无法启动的问题。本 PR 调整了读取 Java 信息的机制,现在 HMCL 总是通过运行 Java 来获取信息。为了降低开销,我们现在使用一个缓存文件来缓存读取到的 Java 信息。