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);
|
Controllers.dialog(i18n("launch.advice.different_platform"), i18n("message.warning"), MessageType.ERROR, continueAction);
|
||||||
suggested = true;
|
suggested = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
// 32-bit JVM cannot make use of too much memory.
|
// 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) {
|
setting.getMaxMemory() > 1.5 * 1024) {
|
||||||
// 1.5 * 1024 is an inaccurate number.
|
// 1.5 * 1024 is an inaccurate number.
|
||||||
// Actual memory limit depends on operating system and memory.
|
// Actual memory limit depends on operating system and memory.
|
||||||
|
|||||||
@@ -608,7 +608,7 @@ public final class VersionSetting implements Cloneable {
|
|||||||
if (checkJava)
|
if (checkJava)
|
||||||
return JavaVersion.fromExecutable(Paths.get(getJavaDir()));
|
return JavaVersion.fromExecutable(Paths.get(getJavaDir()));
|
||||||
else
|
else
|
||||||
return new JavaVersion(Paths.get(getJavaDir()), "", Architecture.SYSTEM.getPlatform());
|
return new JavaVersion(Paths.get(getJavaDir()), "", Architecture.SYSTEM.getBits());
|
||||||
} catch (IOException | InvalidPathException e) {
|
} catch (IOException | InvalidPathException e) {
|
||||||
return null; // Custom Java Directory not found,
|
return null; // Custom Java Directory not found,
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -94,7 +94,7 @@ public class Library implements Comparable<Library>, Validation {
|
|||||||
public String getClassifier() {
|
public String getClassifier() {
|
||||||
if (artifact.getClassifier() == null)
|
if (artifact.getClassifier() == null)
|
||||||
if (natives != null && natives.containsKey(OperatingSystem.CURRENT_OS))
|
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
|
else
|
||||||
return null;
|
return null;
|
||||||
else
|
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.JavaVersion;
|
||||||
import org.jackhuang.hmcl.util.platform.ManagedProcess;
|
import org.jackhuang.hmcl.util.platform.ManagedProcess;
|
||||||
import org.jackhuang.hmcl.util.platform.OperatingSystem;
|
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.BufferedWriter;
|
||||||
import java.io.File;
|
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,
|
// 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.
|
// 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");
|
res.addDefault("-Xss", "1m");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -22,8 +22,8 @@ import org.jackhuang.hmcl.util.StringUtils;
|
|||||||
import java.util.Locale;
|
import java.util.Locale;
|
||||||
import java.util.Optional;
|
import java.util.Optional;
|
||||||
|
|
||||||
import static org.jackhuang.hmcl.util.platform.Platform.BIT_32;
|
import static org.jackhuang.hmcl.util.platform.Bits.BIT_32;
|
||||||
import static org.jackhuang.hmcl.util.platform.Platform.BIT_64;
|
import static org.jackhuang.hmcl.util.platform.Bits.BIT_64;
|
||||||
|
|
||||||
public enum Architecture {
|
public enum Architecture {
|
||||||
X86(BIT_32),
|
X86(BIT_32),
|
||||||
@@ -45,16 +45,16 @@ public enum Architecture {
|
|||||||
S390(BIT_32),
|
S390(BIT_32),
|
||||||
S390X(BIT_64),
|
S390X(BIT_64),
|
||||||
RISCV(BIT_64),
|
RISCV(BIT_64),
|
||||||
UNKNOWN(Platform.UNKNOWN);
|
UNKNOWN(Bits.UNKNOWN);
|
||||||
|
|
||||||
private final Platform platform;
|
private final Bits bits;
|
||||||
|
|
||||||
Architecture(Platform platform) {
|
Architecture(Bits bits) {
|
||||||
this.platform = platform;
|
this.bits = bits;
|
||||||
}
|
}
|
||||||
|
|
||||||
public Platform getPlatform() {
|
public Bits getBits() {
|
||||||
return platform;
|
return bits;
|
||||||
}
|
}
|
||||||
|
|
||||||
public static final String SYSTEM_ARCHITECTURE;
|
public static final String SYSTEM_ARCHITECTURE;
|
||||||
|
|||||||
@@ -28,15 +28,15 @@ import java.lang.reflect.Type;
|
|||||||
*
|
*
|
||||||
* @author huangyuhui
|
* @author huangyuhui
|
||||||
*/
|
*/
|
||||||
@JsonAdapter(Platform.Serializer.class)
|
@JsonAdapter(Bits.Serializer.class)
|
||||||
public enum Platform {
|
public enum Bits {
|
||||||
BIT_32("32"),
|
BIT_32("32"),
|
||||||
BIT_64("64"),
|
BIT_64("64"),
|
||||||
UNKNOWN("unknown");
|
UNKNOWN("unknown");
|
||||||
|
|
||||||
private final String bit;
|
private final String bit;
|
||||||
|
|
||||||
Platform(String bit) {
|
Bits(String bit) {
|
||||||
this.bit = 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
|
@Override
|
||||||
public JsonElement serialize(Platform t, Type type, JsonSerializationContext jsc) {
|
public JsonElement serialize(Bits t, Type type, JsonSerializationContext jsc) {
|
||||||
if (t == null)
|
if (t == null)
|
||||||
return null;
|
return null;
|
||||||
else
|
else
|
||||||
@@ -64,7 +64,7 @@ public enum Platform {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@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)
|
if (je == null)
|
||||||
return null;
|
return null;
|
||||||
else
|
else
|
||||||
@@ -46,10 +46,10 @@ public final class JavaVersion {
|
|||||||
|
|
||||||
private final Path binary;
|
private final Path binary;
|
||||||
private final String longVersion;
|
private final String longVersion;
|
||||||
private final Platform platform;
|
private final Bits platform;
|
||||||
private final int version;
|
private final int version;
|
||||||
|
|
||||||
public JavaVersion(Path binary, String longVersion, Platform platform) {
|
public JavaVersion(Path binary, String longVersion, Bits platform) {
|
||||||
this.binary = binary;
|
this.binary = binary;
|
||||||
this.longVersion = longVersion;
|
this.longVersion = longVersion;
|
||||||
this.platform = platform;
|
this.platform = platform;
|
||||||
@@ -64,7 +64,7 @@ public final class JavaVersion {
|
|||||||
return longVersion;
|
return longVersion;
|
||||||
}
|
}
|
||||||
|
|
||||||
public Platform getPlatform() {
|
public Bits getPlatform() {
|
||||||
return platform;
|
return platform;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -115,7 +115,7 @@ public final class JavaVersion {
|
|||||||
if (cachedJavaVersion != null)
|
if (cachedJavaVersion != null)
|
||||||
return cachedJavaVersion;
|
return cachedJavaVersion;
|
||||||
|
|
||||||
Platform platform = Platform.BIT_32;
|
Bits platform = Bits.BIT_32;
|
||||||
String version = null;
|
String version = null;
|
||||||
|
|
||||||
Process process = new ProcessBuilder(executable.toString(), "-version").start();
|
Process process = new ProcessBuilder(executable.toString(), "-version").start();
|
||||||
@@ -125,7 +125,7 @@ public final class JavaVersion {
|
|||||||
if (m.find())
|
if (m.find())
|
||||||
version = m.group("version");
|
version = m.group("version");
|
||||||
if (line.contains("64-Bit"))
|
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(
|
CURRENT_JAVA = new JavaVersion(
|
||||||
currentExecutable,
|
currentExecutable,
|
||||||
System.getProperty("java.version"),
|
System.getProperty("java.version"),
|
||||||
Architecture.JDK.getPlatform());
|
Architecture.JDK.getBits());
|
||||||
}
|
}
|
||||||
|
|
||||||
private static Collection<JavaVersion> JAVAS;
|
private static Collection<JavaVersion> JAVAS;
|
||||||
|
|||||||
Reference in New Issue
Block a user