summaryrefslogtreecommitdiffstats
path: root/src/java/com/jogamp/common/os
diff options
context:
space:
mode:
authorSven Gothel <[email protected]>2013-06-18 01:41:30 +0200
committerSven Gothel <[email protected]>2013-06-18 01:41:30 +0200
commit4feb65517ae4a4e2b9b04cdfc4b85582cb8b9784 (patch)
treeb043abfa0ae00ed3915862730e35ef15c9f7f630 /src/java/com/jogamp/common/os
parente18771cc020f6fd42f6427540c079e48699ab310 (diff)
Robostness: Catch Throwables on NativeLibrary.open(..) and be verbose in DEBUG mode ; DynamicLinker: Add 'String getLastError()'.
Diffstat (limited to 'src/java/com/jogamp/common/os')
-rw-r--r--src/java/com/jogamp/common/os/DynamicLinker.java1
-rw-r--r--src/java/com/jogamp/common/os/NativeLibrary.java25
2 files changed, 20 insertions, 6 deletions
diff --git a/src/java/com/jogamp/common/os/DynamicLinker.java b/src/java/com/jogamp/common/os/DynamicLinker.java
index 32aa7eb..b1671b9 100644
--- a/src/java/com/jogamp/common/os/DynamicLinker.java
+++ b/src/java/com/jogamp/common/os/DynamicLinker.java
@@ -51,4 +51,5 @@ public interface DynamicLinker {
public long lookupSymbol(long libraryHandle, String symbolName);
public long lookupSymbolGlobal(String symbolName);
public void closeLibrary(long libraryHandle);
+ public String getLastError();
}
diff --git a/src/java/com/jogamp/common/os/NativeLibrary.java b/src/java/com/jogamp/common/os/NativeLibrary.java
index bfc5b07..3009ef3 100644
--- a/src/java/com/jogamp/common/os/NativeLibrary.java
+++ b/src/java/com/jogamp/common/os/NativeLibrary.java
@@ -186,13 +186,26 @@ public class NativeLibrary implements DynamicLookupHelper {
for (Iterator<String> iter = possiblePaths.iterator(); iter.hasNext(); ) {
String path = iter.next();
if (DEBUG) {
- System.err.println("NativeLibrary.open(): Trying to load " + path);
+ System.err.println("NativeLibrary.open(global "+global+"): Trying to load " + path);
}
long res;
- if(global) {
- res = dynLink.openLibraryGlobal(path, DEBUG);
- } else {
- res = dynLink.openLibraryLocal(path, DEBUG);
+ try {
+ if(global) {
+ res = dynLink.openLibraryGlobal(path, DEBUG);
+ } else {
+ res = dynLink.openLibraryLocal(path, DEBUG);
+ }
+ } catch (Throwable t1) {
+ if( DEBUG ) {
+ System.err.println("NativeLibrary.open: Catched "+t1.getClass().getSimpleName()+": "+t1.getMessage());
+ String errstr;
+ try {
+ errstr = dynLink.getLastError();
+ } catch (Throwable t2) { errstr=null; }
+ System.err.println("NativeLibrary.open: Last error "+errstr);
+ t1.printStackTrace();
+ }
+ res = 0;
}
if (res != 0) {
return new NativeLibrary(res, path, global);
@@ -200,7 +213,7 @@ public class NativeLibrary implements DynamicLookupHelper {
}
if (DEBUG) {
- System.err.println("NativeLibrary.open(): Did not succeed in loading (" + windowsLibName + ", " + unixLibName + ", " + macOSXLibName + ")");
+ System.err.println("NativeLibrary.open(global "+global+"): Did not succeed in loading (" + windowsLibName + ", " + unixLibName + ", " + macOSXLibName + ")");
}
// For now, just return null to indicate the open operation didn't