diff options
author | Sven Gothel <[email protected]> | 2012-02-25 17:29:11 +0100 |
---|---|---|
committer | Sven Gothel <[email protected]> | 2012-02-25 17:29:11 +0100 |
commit | b6885506215bbc02b9b805d0c9ace2a134b2c61d (patch) | |
tree | 274dd7334c35e20068df3bfc1248c61d043d124a | |
parent | 9e66972c193399d6dcdf9e6662f4335bdf15736a (diff) |
enhancement: NWJNILibLoader.loadNativeWindow(..) returns true/false if loading was successful. Negative result causes proper exception in caller.
5 files changed, 17 insertions, 10 deletions
diff --git a/src/nativewindow/classes/jogamp/nativewindow/NWJNILibLoader.java b/src/nativewindow/classes/jogamp/nativewindow/NWJNILibLoader.java index 4cf8f448e..be41ad719 100644 --- a/src/nativewindow/classes/jogamp/nativewindow/NWJNILibLoader.java +++ b/src/nativewindow/classes/jogamp/nativewindow/NWJNILibLoader.java @@ -38,18 +38,17 @@ import com.jogamp.common.util.cache.TempJarCache; public class NWJNILibLoader extends JNILibLoaderBase { - public static void loadNativeWindow(final String ossuffix) { - AccessController.doPrivileged(new PrivilegedAction<Object>() { - public Object run() { + public static boolean loadNativeWindow(final String ossuffix) { + return AccessController.doPrivileged(new PrivilegedAction<Boolean>() { + public Boolean run() { Platform.initSingleton(); final String libName = "nativewindow_"+ossuffix ; if(TempJarCache.isInitialized() && null == TempJarCache.findLibrary(libName)) { addNativeJarLibs(NWJNILibLoader.class, "jogl-all", new String[] { "nativewindow" } ); } - loadLibrary(libName, false); - return null; + return new Boolean(loadLibrary(libName, false)); } - }); + }).booleanValue(); } } diff --git a/src/nativewindow/classes/jogamp/nativewindow/jawt/JAWTUtil.java b/src/nativewindow/classes/jogamp/nativewindow/jawt/JAWTUtil.java index a9326cc4a..2ecbc61e2 100644 --- a/src/nativewindow/classes/jogamp/nativewindow/jawt/JAWTUtil.java +++ b/src/nativewindow/classes/jogamp/nativewindow/jawt/JAWTUtil.java @@ -168,7 +168,9 @@ public class JAWTUtil { // Thread.dumpStack(); } JAWTJNILibLoader.initSingleton(); - JAWTJNILibLoader.loadNativeWindow("awt"); + if(!JAWTJNILibLoader.loadNativeWindow("awt")) { + throw new NativeWindowException("NativeWindow AWT native library load error."); + } headlessMode = GraphicsEnvironment.isHeadless(); boolean ok = false; diff --git a/src/nativewindow/classes/jogamp/nativewindow/macosx/OSXUtil.java b/src/nativewindow/classes/jogamp/nativewindow/macosx/OSXUtil.java index 5b1e4b0a7..3ca76a84a 100644 --- a/src/nativewindow/classes/jogamp/nativewindow/macosx/OSXUtil.java +++ b/src/nativewindow/classes/jogamp/nativewindow/macosx/OSXUtil.java @@ -39,7 +39,9 @@ public class OSXUtil { public static synchronized void initSingleton(boolean firstX11ActionOnProcess) { if(!isInit) { - NWJNILibLoader.loadNativeWindow("macosx"); + if(!NWJNILibLoader.loadNativeWindow("macosx")) { + throw new NativeWindowException("NativeWindow MacOSX native library load error."); + } if( !initIDs0() ) { throw new NativeWindowException("MacOSX: Could not initialized native stub"); diff --git a/src/nativewindow/classes/jogamp/nativewindow/windows/GDIUtil.java b/src/nativewindow/classes/jogamp/nativewindow/windows/GDIUtil.java index be531d9ee..d17a1898c 100644 --- a/src/nativewindow/classes/jogamp/nativewindow/windows/GDIUtil.java +++ b/src/nativewindow/classes/jogamp/nativewindow/windows/GDIUtil.java @@ -46,7 +46,9 @@ public class GDIUtil { synchronized(X11Util.class) { if(!isInit) { isInit = true; - NWJNILibLoader.loadNativeWindow("win32"); + if(!NWJNILibLoader.loadNativeWindow("win32")) { + throw new NativeWindowException("NativeWindow Windows native library load error."); + } if( !initIDs0() ) { throw new NativeWindowException("GDI: Could not initialized native stub"); diff --git a/src/nativewindow/classes/jogamp/nativewindow/x11/X11Util.java b/src/nativewindow/classes/jogamp/nativewindow/x11/X11Util.java index 560130dd1..7e5155771 100644 --- a/src/nativewindow/classes/jogamp/nativewindow/x11/X11Util.java +++ b/src/nativewindow/classes/jogamp/nativewindow/x11/X11Util.java @@ -101,7 +101,9 @@ public class X11Util { synchronized(X11Util.class) { if(!isInit) { isInit = true; - NWJNILibLoader.loadNativeWindow("x11"); + if(!NWJNILibLoader.loadNativeWindow("x11")) { + throw new NativeWindowException("NativeWindow X11 native library load error."); + } final boolean callXInitThreads = XINITTHREADS_ALWAYS_ENABLED || firstX11ActionOnProcess; final boolean isXInitThreadsOK = initialize0( XINITTHREADS_ALWAYS_ENABLED || firstX11ActionOnProcess ); |