bit more of a robust method of checking if running on a 32-bit jvm

os.arch can have a wide variety of values (e.g. not just "x86" for
32 bit)
This commit is contained in:
Gered 2017-04-14 12:40:48 -04:00
parent e5721392c6
commit c0a65e037c

View file

@ -76,12 +76,18 @@ public class Mirror {
return true;
}
static {
String arch = System.getProperty("os.arch");
if(!arch.equals("x86")){
throw new UnsupportedOperationException("BWMirror API supports only x86 architecture.");
public static boolean is64BitJRE() {
String bits = System.getProperty("sun.arch.data.model");
if (bits == null)
return System.getProperty("java.vm.name").contains("64");
else
return bits.equals("64");
}
static {
if (is64BitJRE())
throw new UnsupportedOperationException("BWMirror must be run on a 32-bit JRE/JDK.");
if (!extractAndLoadNativeLibraries())
System.exit(1);
if (!extractBwtaDataFiles())