Rename 'Platform' to 'Bits'
This commit is contained in:
@@ -432,13 +432,13 @@ public final class LauncherHelper {
|
||||
}
|
||||
}
|
||||
|
||||
if (javaVersion.getPlatform() != Architecture.SYSTEM.getPlatform()) {
|
||||
if (javaVersion.getPlatform() != Architecture.SYSTEM.getBits()) {
|
||||
Controllers.dialog(i18n("launch.advice.different_platform"), i18n("message.warning"), MessageType.ERROR, continueAction);
|
||||
suggested = true;
|
||||
}
|
||||
|
||||
// 32-bit JVM cannot make use of too much memory.
|
||||
if (javaVersion.getPlatform() == org.jackhuang.hmcl.util.platform.Platform.BIT_32 &&
|
||||
if (javaVersion.getPlatform() == Bits.BIT_32 &&
|
||||
setting.getMaxMemory() > 1.5 * 1024) {
|
||||
// 1.5 * 1024 is an inaccurate number.
|
||||
// Actual memory limit depends on operating system and memory.
|
||||
|
||||
@@ -608,7 +608,7 @@ public final class VersionSetting implements Cloneable {
|
||||
if (checkJava)
|
||||
return JavaVersion.fromExecutable(Paths.get(getJavaDir()));
|
||||
else
|
||||
return new JavaVersion(Paths.get(getJavaDir()), "", Architecture.SYSTEM.getPlatform());
|
||||
return new JavaVersion(Paths.get(getJavaDir()), "", Architecture.SYSTEM.getBits());
|
||||
} catch (IOException | InvalidPathException e) {
|
||||
return null; // Custom Java Directory not found,
|
||||
}
|
||||
|
||||
@@ -94,7 +94,7 @@ public class Library implements Comparable<Library>, Validation {
|
||||
public String getClassifier() {
|
||||
if (artifact.getClassifier() == null)
|
||||
if (natives != null && natives.containsKey(OperatingSystem.CURRENT_OS))
|
||||
return natives.get(OperatingSystem.CURRENT_OS).replace("${arch}", Architecture.SYSTEM.getPlatform().getBit());
|
||||
return natives.get(OperatingSystem.CURRENT_OS).replace("${arch}", Architecture.SYSTEM.getBits().getBit());
|
||||
else
|
||||
return null;
|
||||
else
|
||||
|
||||
@@ -36,7 +36,7 @@ import org.jackhuang.hmcl.util.platform.CommandBuilder;
|
||||
import org.jackhuang.hmcl.util.platform.JavaVersion;
|
||||
import org.jackhuang.hmcl.util.platform.ManagedProcess;
|
||||
import org.jackhuang.hmcl.util.platform.OperatingSystem;
|
||||
import org.jackhuang.hmcl.util.platform.Platform;
|
||||
import org.jackhuang.hmcl.util.platform.Bits;
|
||||
|
||||
import java.io.BufferedWriter;
|
||||
import java.io.File;
|
||||
@@ -160,7 +160,7 @@ public class DefaultLauncher extends Launcher {
|
||||
|
||||
// As 32-bit JVM allocate 320KB for stack by default rather than 64-bit version allocating 1MB,
|
||||
// causing Minecraft 1.13 crashed accounting for java.lang.StackOverflowError.
|
||||
if (options.getJava().getPlatform() == Platform.BIT_32) {
|
||||
if (options.getJava().getPlatform() == Bits.BIT_32) {
|
||||
res.addDefault("-Xss", "1m");
|
||||
}
|
||||
|
||||
|
||||
@@ -22,8 +22,8 @@ import org.jackhuang.hmcl.util.StringUtils;
|
||||
import java.util.Locale;
|
||||
import java.util.Optional;
|
||||
|
||||
import static org.jackhuang.hmcl.util.platform.Platform.BIT_32;
|
||||
import static org.jackhuang.hmcl.util.platform.Platform.BIT_64;
|
||||
import static org.jackhuang.hmcl.util.platform.Bits.BIT_32;
|
||||
import static org.jackhuang.hmcl.util.platform.Bits.BIT_64;
|
||||
|
||||
public enum Architecture {
|
||||
X86(BIT_32),
|
||||
@@ -45,16 +45,16 @@ public enum Architecture {
|
||||
S390(BIT_32),
|
||||
S390X(BIT_64),
|
||||
RISCV(BIT_64),
|
||||
UNKNOWN(Platform.UNKNOWN);
|
||||
UNKNOWN(Bits.UNKNOWN);
|
||||
|
||||
private final Platform platform;
|
||||
private final Bits bits;
|
||||
|
||||
Architecture(Platform platform) {
|
||||
this.platform = platform;
|
||||
Architecture(Bits bits) {
|
||||
this.bits = bits;
|
||||
}
|
||||
|
||||
public Platform getPlatform() {
|
||||
return platform;
|
||||
public Bits getBits() {
|
||||
return bits;
|
||||
}
|
||||
|
||||
public static final String SYSTEM_ARCHITECTURE;
|
||||
|
||||
@@ -28,15 +28,15 @@ import java.lang.reflect.Type;
|
||||
*
|
||||
* @author huangyuhui
|
||||
*/
|
||||
@JsonAdapter(Platform.Serializer.class)
|
||||
public enum Platform {
|
||||
@JsonAdapter(Bits.Serializer.class)
|
||||
public enum Bits {
|
||||
BIT_32("32"),
|
||||
BIT_64("64"),
|
||||
UNKNOWN("unknown");
|
||||
|
||||
private final String bit;
|
||||
|
||||
Platform(String bit) {
|
||||
Bits(String bit) {
|
||||
this.bit = bit;
|
||||
}
|
||||
|
||||
@@ -45,11 +45,11 @@ public enum Platform {
|
||||
}
|
||||
|
||||
/**
|
||||
* The json serializer to {@link Platform}.
|
||||
* The json serializer to {@link Bits}.
|
||||
*/
|
||||
public static class Serializer implements JsonSerializer<Platform>, JsonDeserializer<Platform> {
|
||||
public static class Serializer implements JsonSerializer<Bits>, JsonDeserializer<Bits> {
|
||||
@Override
|
||||
public JsonElement serialize(Platform t, Type type, JsonSerializationContext jsc) {
|
||||
public JsonElement serialize(Bits t, Type type, JsonSerializationContext jsc) {
|
||||
if (t == null)
|
||||
return null;
|
||||
else
|
||||
@@ -64,7 +64,7 @@ public enum Platform {
|
||||
}
|
||||
|
||||
@Override
|
||||
public Platform deserialize(JsonElement je, Type type, JsonDeserializationContext jdc) throws JsonParseException {
|
||||
public Bits deserialize(JsonElement je, Type type, JsonDeserializationContext jdc) throws JsonParseException {
|
||||
if (je == null)
|
||||
return null;
|
||||
else
|
||||
@@ -46,10 +46,10 @@ public final class JavaVersion {
|
||||
|
||||
private final Path binary;
|
||||
private final String longVersion;
|
||||
private final Platform platform;
|
||||
private final Bits platform;
|
||||
private final int version;
|
||||
|
||||
public JavaVersion(Path binary, String longVersion, Platform platform) {
|
||||
public JavaVersion(Path binary, String longVersion, Bits platform) {
|
||||
this.binary = binary;
|
||||
this.longVersion = longVersion;
|
||||
this.platform = platform;
|
||||
@@ -64,7 +64,7 @@ public final class JavaVersion {
|
||||
return longVersion;
|
||||
}
|
||||
|
||||
public Platform getPlatform() {
|
||||
public Bits getPlatform() {
|
||||
return platform;
|
||||
}
|
||||
|
||||
@@ -115,7 +115,7 @@ public final class JavaVersion {
|
||||
if (cachedJavaVersion != null)
|
||||
return cachedJavaVersion;
|
||||
|
||||
Platform platform = Platform.BIT_32;
|
||||
Bits platform = Bits.BIT_32;
|
||||
String version = null;
|
||||
|
||||
Process process = new ProcessBuilder(executable.toString(), "-version").start();
|
||||
@@ -125,7 +125,7 @@ public final class JavaVersion {
|
||||
if (m.find())
|
||||
version = m.group("version");
|
||||
if (line.contains("64-Bit"))
|
||||
platform = Platform.BIT_64;
|
||||
platform = Bits.BIT_64;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -163,7 +163,7 @@ public final class JavaVersion {
|
||||
CURRENT_JAVA = new JavaVersion(
|
||||
currentExecutable,
|
||||
System.getProperty("java.version"),
|
||||
Architecture.JDK.getPlatform());
|
||||
Architecture.JDK.getBits());
|
||||
}
|
||||
|
||||
private static Collection<JavaVersion> JAVAS;
|
||||
|
||||
Reference in New Issue
Block a user