mirror of
https://github.com/HMCL-dev/HMCL.git
synced 2025-03-07 17:36:52 +08:00
fix: crash when JavaSoft registries are malformed.
This commit is contained in:
parent
b2693cd3f9
commit
4f70465395
@ -25,6 +25,7 @@ import java.io.BufferedReader;
|
||||
import java.io.IOException;
|
||||
import java.io.InputStreamReader;
|
||||
import java.nio.file.Files;
|
||||
import java.nio.file.InvalidPathException;
|
||||
import java.nio.file.Path;
|
||||
import java.nio.file.Paths;
|
||||
import java.util.ArrayList;
|
||||
@ -259,7 +260,11 @@ public final class JavaVersion {
|
||||
continue;
|
||||
String home = queryRegisterValue(java, "JavaHome");
|
||||
if (home != null) {
|
||||
homes.add(Paths.get(home));
|
||||
try {
|
||||
homes.add(Paths.get(home));
|
||||
} catch (InvalidPathException e) {
|
||||
LOG.log(Level.WARNING, "Invalid Java path in system registry: " + home);
|
||||
}
|
||||
}
|
||||
}
|
||||
return homes;
|
||||
|
Loading…
Reference in New Issue
Block a user