Avoid throwing NPE when the Java version cannot be obtained

This commit is contained in:
Glavo 2021-10-23 21:35:37 +08:00 committed by Yuhui Huang
parent 651aedaa50
commit 8b224cb240

View File

@ -54,8 +54,14 @@ public final class JavaVersion {
this.binary = binary; this.binary = binary;
this.longVersion = longVersion; this.longVersion = longVersion;
this.platform = platform; this.platform = platform;
version = parseVersion(longVersion);
versionNumber = VersionNumber.asVersion(longVersion); if (longVersion != null) {
version = parseVersion(longVersion);
versionNumber = VersionNumber.asVersion(longVersion);
} else {
version = UNKNOWN;
versionNumber = null;
}
} }
public Path getBinary() { public Path getBinary() {