private static final int osType;
String osName = System.getProperty("os.name");
if (osName.startsWith("Linux")) {
if ("dalvik".equals(System.getProperty("java.vm.name").toLowerCase())) {
osType = ANDROID;
// Native libraries on android must be bundled with the APK
System.setProperty("jna.nounpack", "true");
}
else {
osType = LINUX;
}
}
else if (osName.startsWith("AIX")) {
osType = AIX;
}
else if (osName.startsWith("Mac") || osName.startsWith("Darwin")) {
osType = MAC;
}
else if (osName.startsWith("Windows CE")) {
osType = WINDOWSCE;
}
else if (osName.startsWith("Windows")) {
osType = WINDOWS;
}
else if (osName.startsWith("Solaris") || osName.startsWith("SunOS")) {
osType = SOLARIS;
}
else if (osName.startsWith("FreeBSD")) {
osType = FREEBSD;
}
else if (osName.startsWith("OpenBSD")) {
osType = OPENBSD;
}
else if (osName.equalsIgnoreCase("gnu")) {
osType = GNU;
}
else if (osName.equalsIgnoreCase("gnu/kfreebsd")) {
osType = KFREEBSD;
}
else if (osName.equalsIgnoreCase("netbsd")) {
osType = NETBSD;
}
else {
osType = UNSPECIFIED;
}
boolean hasBuffers = false;
try {
Class.forName("java.nio.Buffer");
hasBuffers = true;
}
catch(ClassNotFoundException e) {
}
// NOTE: we used to do Class.forName("java.awt.Component"), but that
// has the unintended side effect of actually loading AWT native libs,
// which can be problematic
HAS_AWT = osType != WINDOWSCE && osType != ANDROID && osType != AIX;
HAS_JAWT = HAS_AWT && osType != MAC;
HAS_BUFFERS = hasBuffers;
RO_FIELDS = osType != WINDOWSCE;
C_LIBRARY_NAME = osType == WINDOWS ? "msvcrt" : osType == WINDOWSCE ? "coredll" : "c";
MATH_LIBRARY_NAME = osType == WINDOWS ? "msvcrt" : osType == WINDOWSCE ? "coredll" : "m";
HAS_DLL_CALLBACKS = osType == WINDOWS;
ARCH = getCanonicalArchitecture(System.getProperty("os.arch"), osType);
RESOURCE_PREFIX = getNativeLibraryResourcePrefix();
}
String osName = System.getProperty("os.name");