mirror of
https://github.com/HMCL-dev/HMCL.git
synced 2025-02-23 17:19:44 +08:00
Update JavaVersionConstraint (#1683)
This commit is contained in:
parent
a5af5265be
commit
058a8e2335
@ -120,8 +120,16 @@ public enum JavaVersionConstraint {
|
||||
@Override
|
||||
protected boolean appliesToVersionImpl(VersionNumber gameVersionNumber, @Nullable Version version,
|
||||
@Nullable JavaVersion javaVersion) {
|
||||
return javaVersion != null && !javaVersion.getArchitecture().isX86()
|
||||
&& (OperatingSystem.CURRENT_OS != OperatingSystem.OSX || gameVersionNumber.compareTo(VersionNumber.asVersion("1.19")) < 0);
|
||||
if (javaVersion == null || javaVersion.getArchitecture() != Architecture.ARM64)
|
||||
return false;
|
||||
|
||||
if (OperatingSystem.CURRENT_OS == OperatingSystem.WINDOWS)
|
||||
return gameVersionNumber.compareTo(VersionNumber.asVersion("1.6")) < 0;
|
||||
|
||||
if (OperatingSystem.CURRENT_OS == OperatingSystem.OSX)
|
||||
return gameVersionNumber.compareTo(VersionNumber.asVersion("1.19")) < 0;
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -6,27 +6,19 @@ public final class Platform {
|
||||
public static final Platform UNKNOWN = new Platform(OperatingSystem.UNKNOWN, Architecture.UNKNOWN);
|
||||
|
||||
public static final Platform WINDOWS_X86_64 = new Platform(OperatingSystem.WINDOWS, Architecture.X86_64);
|
||||
public static final Platform OSX_X86_64 = new Platform(OperatingSystem.OSX, Architecture.X86_64);
|
||||
public static final Platform LINUX_X86_64 = new Platform(OperatingSystem.LINUX, Architecture.X86_64);
|
||||
public static final Platform WINDOWS_ARM64 = new Platform(OperatingSystem.WINDOWS, Architecture.ARM64);
|
||||
|
||||
public static final Platform LINUX_X86_64 = new Platform(OperatingSystem.LINUX, Architecture.X86_64);
|
||||
public static final Platform LINUX_ARM64 = new Platform(OperatingSystem.LINUX, Architecture.ARM64);
|
||||
|
||||
public static final Platform OSX_X86_64 = new Platform(OperatingSystem.OSX, Architecture.X86_64);
|
||||
public static final Platform OSX_ARM64 = new Platform(OperatingSystem.OSX, Architecture.ARM64);
|
||||
|
||||
public static final Platform CURRENT_PLATFORM = Platform.getPlatform(OperatingSystem.CURRENT_OS, Architecture.CURRENT_ARCH);
|
||||
public static final Platform SYSTEM_PLATFORM = Platform.getPlatform(OperatingSystem.CURRENT_OS, Architecture.SYSTEM_ARCH);
|
||||
|
||||
public static boolean isCompatibleWithX86Java() {
|
||||
if (Architecture.CURRENT_ARCH.isX86())
|
||||
return true;
|
||||
|
||||
// Rosetta 2 is available for Mac computers with Apple silicon
|
||||
if (CURRENT_PLATFORM == OSX_ARM64)
|
||||
return true;
|
||||
|
||||
// Windows on ARM introduced translation support for x86-64 after 10.0.21277.
|
||||
if (OperatingSystem.CURRENT_OS == OperatingSystem.WINDOWS && OperatingSystem.SYSTEM_BUILD_NUMBER >= 21277)
|
||||
return true;
|
||||
|
||||
return false;
|
||||
return Architecture.SYSTEM_ARCH.isX86() || SYSTEM_PLATFORM == OSX_ARM64 || SYSTEM_PLATFORM == WINDOWS_ARM64;
|
||||
}
|
||||
|
||||
private final OperatingSystem os;
|
||||
@ -55,8 +47,15 @@ public final class Platform {
|
||||
case LINUX:
|
||||
return LINUX_X86_64;
|
||||
}
|
||||
} else if (arch == Architecture.ARM64 && OperatingSystem.CURRENT_OS == OperatingSystem.OSX) {
|
||||
return OSX_ARM64;
|
||||
} else if (arch == Architecture.ARM64) {
|
||||
switch (os) {
|
||||
case WINDOWS:
|
||||
return WINDOWS_ARM64;
|
||||
case OSX:
|
||||
return OSX_ARM64;
|
||||
case LINUX:
|
||||
return LINUX_ARM64;
|
||||
}
|
||||
}
|
||||
|
||||
return new Platform(os, arch);
|
||||
|
Loading…
Reference in New Issue
Block a user