Conversation
There was a problem hiding this comment.
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.
|
@codex review |
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 1fe1623c9d
ℹ️ 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".
|
/gemini review |
There was a problem hiding this comment.
Pull request overview
Copilot reviewed 5 out of 5 changed files in this pull request and generated 5 comments.
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
There was a problem hiding this comment.
Code Review
This pull request refactors the Java runtime discovery and management logic, primarily by introducing a caching mechanism to improve performance. A new Searcher inner class in JavaManager handles the search process and persists results to javaCache.json. Additionally, the JavaInfo class was updated to use a builder pattern and switch expressions, and several internal APIs were simplified to return Path collections instead of JavaRuntime objects during the discovery phase. My feedback focuses on optimizing the cache loading and key generation logic to avoid redundant operations and potential performance bottlenecks during I/O-heavy tasks.
|
|
||
| Path releaseFile = javaHome.resolve("release"); | ||
| if (Files.exists(releaseFile)) { | ||
| releaseHash = DigestUtils.digestToString("SHA-1", releaseFile); |
There was a problem hiding this comment.
Using DigestUtils.digestToString("SHA-1", releaseFile) to hash the entire release file every time the cache key is generated might be inefficient if there are many Java installations. While release files are generally small, reading and hashing the file content on every search adds unnecessary I/O overhead. Since you are already including the executable's size and last modified time in the cache key (lines 642-643), you could consider using only the release file's attributes (size and last modified time) instead of its full content hash to improve performance.
之前我们依靠读取
release文件加速读取 Java 信息。但是release文件包含的信息较少,而且我们无法从release文件中得知该 Java 是否能正常工作,所以可能会造成游戏无法启动的问题。本 PR 调整了读取 Java 信息的机制,现在 HMCL 总是通过运行 Java 来获取信息。为了降低开销,我们现在使用一个缓存文件来缓存读取到的 Java 信息。