mirror of
https://github.com/HMCL-dev/HMCL.git
synced 2025-09-17 07:47:57 -04:00
Fix: not recognizing java 12
This commit is contained in:
parent
d4155bc14d
commit
993ce660aa
@ -303,7 +303,7 @@ public final class LauncherHelper {
|
||||
}
|
||||
|
||||
// LaunchWrapper 1.12 will crash because of assuming the system class loader is an instance of URLClassLoader.
|
||||
if (!flag && java.getParsedVersion() >= JavaVersion.JAVA_9
|
||||
if (!flag && java.getParsedVersion() >= JavaVersion.JAVA_9_AND_LATER
|
||||
&& version.getMainClass().contains("launchwrapper")
|
||||
&& version.getLibraries().stream()
|
||||
.filter(library -> "launchwrapper".equals(library.getArtifactId()))
|
||||
|
@ -206,7 +206,7 @@ public class DefaultLauncher extends Launcher {
|
||||
}
|
||||
|
||||
private final Map<String, Supplier<Boolean>> forbiddens = mapOf(
|
||||
pair("-Xincgc", () -> options.getJava().getParsedVersion() >= JavaVersion.JAVA_9)
|
||||
pair("-Xincgc", () -> options.getJava().getParsedVersion() >= JavaVersion.JAVA_9_AND_LATER)
|
||||
);
|
||||
|
||||
protected Map<String, Supplier<Boolean>> getForbiddens() {
|
||||
|
@ -17,6 +17,7 @@
|
||||
*/
|
||||
package org.jackhuang.hmcl.util.platform;
|
||||
|
||||
import org.jackhuang.hmcl.util.Lang;
|
||||
import org.jackhuang.hmcl.util.StringUtils;
|
||||
import org.jackhuang.hmcl.util.versioning.VersionNumber;
|
||||
|
||||
@ -76,9 +77,6 @@ public final class JavaVersion {
|
||||
/**
|
||||
* The major version of Java installation.
|
||||
*
|
||||
* @see org.jackhuang.hmcl.util.platform.JavaVersion#JAVA_11
|
||||
* @see org.jackhuang.hmcl.util.platform.JavaVersion#JAVA_10
|
||||
* @see org.jackhuang.hmcl.util.platform.JavaVersion#JAVA_9
|
||||
* @see org.jackhuang.hmcl.util.platform.JavaVersion#JAVA_8
|
||||
* @see org.jackhuang.hmcl.util.platform.JavaVersion#JAVA_7
|
||||
* @see org.jackhuang.hmcl.util.platform.JavaVersion#UNKNOWN
|
||||
@ -88,22 +86,20 @@ public final class JavaVersion {
|
||||
}
|
||||
|
||||
private static final Pattern REGEX = Pattern.compile("version \"(?<version>(.*?))\"");
|
||||
private static final Pattern VERSION = Pattern.compile("^(?<version>[0-9]+)");
|
||||
|
||||
public static final int UNKNOWN = -1;
|
||||
public static final int JAVA_7 = 70;
|
||||
public static final int JAVA_8 = 80;
|
||||
public static final int JAVA_9 = 90;
|
||||
public static final int JAVA_10 = 100;
|
||||
public static final int JAVA_11 = 110;
|
||||
public static final int JAVA_9_AND_LATER = 90;
|
||||
|
||||
private static int parseVersion(String version) {
|
||||
if (version.startsWith("11"))
|
||||
return JAVA_11;
|
||||
else if (version.startsWith("10"))
|
||||
return JAVA_10;
|
||||
else if (version.startsWith("9"))
|
||||
return JAVA_9;
|
||||
else if (version.contains("1.8"))
|
||||
Matcher matcher = VERSION.matcher(version);
|
||||
if (matcher.find()) {
|
||||
int head = Lang.parseInt(matcher.group(), -1);
|
||||
if (head > 1) return JAVA_9_AND_LATER;
|
||||
}
|
||||
if (version.contains("1.8"))
|
||||
return JAVA_8;
|
||||
else if (version.contains("1.7"))
|
||||
return JAVA_7;
|
||||
|
Loading…
x
Reference in New Issue
Block a user