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; return true;
} }
static { public static boolean is64BitJRE() {
String arch = System.getProperty("os.arch"); String bits = System.getProperty("sun.arch.data.model");
if(!arch.equals("x86")){ if (bits == null)
throw new UnsupportedOperationException("BWMirror API supports only x86 architecture."); 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()) if (!extractAndLoadNativeLibraries())
System.exit(1); System.exit(1);
if (!extractBwtaDataFiles()) if (!extractBwtaDataFiles())