Backported LWJGL 3's handling of System.loadLibrary errors. Resolves #87.

This commit is contained in:
Ioannis Tsakpinis 2014-09-13 13:39:22 +03:00
parent f05778f073
commit f760abeb81
1 changed files with 9 additions and 3 deletions

View File

@ -80,13 +80,15 @@ public final class Sys {
private static void loadLibrary(final String lib_name) {
// actively try to load 64bit libs on 64bit architectures first
String osArch = System.getProperty("os.arch");
boolean is64bit = "amd64".equals(osArch) || "x86_64".equals(osArch);
if(is64bit) {
boolean try64First = LWJGLUtil.getPlatform() != LWJGLUtil.PLATFORM_MACOSX && ("amd64".equals(osArch) || "x86_64".equals(osArch));
Error err = null;
if ( try64First ) {
try {
doLoadLibrary(lib_name + POSTFIX64BIT);
return;
} catch (UnsatisfiedLinkError e) {
LWJGLUtil.log("Failed to load 64 bit library: " + e.getMessage());
err = e;
}
}
@ -94,6 +96,9 @@ public final class Sys {
try {
doLoadLibrary(lib_name);
} catch (UnsatisfiedLinkError e) {
if ( try64First )
throw err;
if (implementation.has64Bit()) {
try {
doLoadLibrary(lib_name + POSTFIX64BIT);
@ -102,6 +107,7 @@ public final class Sys {
LWJGLUtil.log("Failed to load 64 bit library: " + e2.getMessage());
}
}
// Throw original error
throw e;
}