Skip to content

Conversation

@CiiLu
Copy link
Contributor

@CiiLu CiiLu commented Jan 18, 2026

如果使用 Java 8 启动 HMCL 并放在感叹号路径下, Java 版本提示对话框显示不出来

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 pull request fixes an issue where HMCL launched with Java 8 from a directory path containing an exclamation mark would fail to display the Java version error dialog. The fix moves the illegal path validation from EntryPoint to Main (HMCLBoot) to ensure the check occurs before JavaFX initialization.

Changes:

  • Moved the checkDirectoryPath() method from EntryPoint.java to Main.java to perform path validation earlier in the application lifecycle
  • Updated the error logging to use System.err.println() instead of LOG.error() since the logger is not yet initialized in the boot phase

Reviewed changes

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

File Description
HMCLBoot/src/main/java/org/jackhuang/hmcl/Main.java Added checkDirectoryPath() method to validate path before JavaFX initialization, ensuring error dialogs can display on Java 8
HMCL/src/main/java/org/jackhuang/hmcl/EntryPoint.java Removed checkDirectoryPath() method and its invocation, as this check now occurs earlier in the boot process

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

SwingUtils.initLookAndFeel();
System.err.println("The current working path contains an exclamation mark: " + currentDir);
// No Chinese translation because both Swing and JavaFX cannot render Chinese character properly when exclamation mark exists in the path.
SwingUtils.showErrorDialog("Exclamation mark(!) is not allowed in the path where HMCL is in.\n" + "The path is " + currentDir, "ERROR");
Copy link

Copilot AI Jan 19, 2026

Choose a reason for hiding this comment

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

The error dialog title "ERROR" is hardcoded in English, while other error dialogs in this file use resourceBundle.getString("boot.message.error") for the title. While the comment explains that Chinese characters cannot be rendered properly with exclamation marks in the path (hence the English error message), the title could potentially use the same approach as showErrorAndExit() for consistency, or at least use a lowercase "Error" to match the default title pattern in SwingUtils.showErrorDialog().

Suggested change
SwingUtils.showErrorDialog("Exclamation mark(!) is not allowed in the path where HMCL is in.\n" + "The path is " + currentDir, "ERROR");
ResourceBundle resourceBundle = BootProperties.getResourceBundle();
String errorTitle = resourceBundle.getString("boot.message.error");
SwingUtils.showErrorDialog("Exclamation mark(!) is not allowed in the path where HMCL is in.\n" + "The path is " + currentDir, errorTitle);

Copilot uses AI. Check for mistakes.
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