Skip to content

fix: Java 管理页面点击列表项时 Tag 会闪烁#6256

Merged
Glavo merged 2 commits into
HMCL-dev:mainfrom
LuLu-ling:fix/6049
Jun 28, 2026
Merged

fix: Java 管理页面点击列表项时 Tag 会闪烁#6256
Glavo merged 2 commits into
HMCL-dev:mainfrom
LuLu-ling:fix/6049

Conversation

@LuLu-ling

Copy link
Copy Markdown
Contributor

close #6049

Comment thread HMCL/src/main/java/org/jackhuang/hmcl/ui/main/JavaManagementPage.java Outdated
@Glavo

Glavo commented Jun 28, 2026

Copy link
Copy Markdown
Member

/gemini review

@gemini-code-assist gemini-code-assist Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Code Review

This pull request optimizes the Java list rendering in JavaManagementPage by only updating the tags when the JavaRuntime item actually changes. The reviewer pointed out that using reference equality (oldItem != item) might still cause UI flickering when list items are reloaded as new instances, and suggested using !Objects.equals(oldItem, item) instead since JavaRuntime overrides equals based on the binary path.

Important

The consumer version of Gemini Code Assist on GitHub is being sunset. Starting June 18, 2026, new organization installations will be blocked, and all code review activity will officially cease on July 17, 2026.
For more details on the timeline and next steps, please review the Help Documentation.

String vendor = JavaInfo.normalizeVendor(item.getVendor());
if (vendor != null)
content.addTag(i18n("java.info.vendor") + ": " + vendor);
if (oldItem != item) {

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

medium

JavaRuntime 中,equals 方法已被重写为基于 binary 路径进行比较。

当 Java 列表被刷新或重新加载时,可能会为相同的 Java 运行环境创建新的 JavaRuntime 实例。如果使用引用比较 oldItem != item,在刷新列表时,即使是同一个 Java 运行环境,由于实例引用不同,依然会触发 Tag 的清空和重新添加,从而导致闪烁。

建议使用 !Objects.equals(oldItem, item) 进行逻辑等值比较,这样可以更彻底地避免在刷新或重建实例时发生闪烁。

Suggested change
if (oldItem != item) {
if (!Objects.equals(oldItem, item)) {

@Glavo
Glavo merged commit 4baf983 into HMCL-dev:main Jun 28, 2026
2 checks passed
@LuLu-ling
LuLu-ling deleted the fix/6049 branch July 4, 2026 08:55
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.

[Bug] Java 管理页面点击列表项时 Tag 会闪烁

2 participants