summaryrefslogtreecommitdiffstats
path: root/src/nativewindow/classes
diff options
context:
space:
mode:
authorMichael Bien <[email protected]>2010-04-18 00:31:12 +0200
committerSven Gothel <[email protected]>2010-04-19 00:56:25 +0200
commit316e43b5a13012ce5f41a03b8b602105921e872b (patch)
tree20a34faf05a652929b06fc94e17994e90dbccaaa /src/nativewindow/classes
parent5448c24c7e67aca6efbcee78fe5c57de079f01a2 (diff)
code review (http://jogamp.org/bugzilla/show_bug.cgi?id=396): improved exception handling in NWReflection and NativeLibLoaderBase. goal was to prevent catch(Throwable) and to fix or document empty catch blocks where it makes sense.
Diffstat (limited to 'src/nativewindow/classes')
-rw-r--r--src/nativewindow/classes/com/jogamp/nativewindow/impl/NativeLibLoaderBase.java32
1 files changed, 20 insertions, 12 deletions
diff --git a/src/nativewindow/classes/com/jogamp/nativewindow/impl/NativeLibLoaderBase.java b/src/nativewindow/classes/com/jogamp/nativewindow/impl/NativeLibLoaderBase.java
index 0670234..c4f1d7e 100644
--- a/src/nativewindow/classes/com/jogamp/nativewindow/impl/NativeLibLoaderBase.java
+++ b/src/nativewindow/classes/com/jogamp/nativewindow/impl/NativeLibLoaderBase.java
@@ -64,8 +64,7 @@ public class NativeLibLoaderBase {
}
private static class DefaultAction implements LoaderAction {
- public void loadLibrary(String libname, String[] preload,
- boolean preloadIgnoreError) {
+ public void loadLibrary(String libname, String[] preload, boolean preloadIgnoreError) {
if (null!=preload) {
for (int i=0; i<preload.length; i++) {
if(!isLoaded(preload[i])) {
@@ -75,9 +74,10 @@ public class NativeLibLoaderBase {
if(DEBUG) {
System.err.println("NativeLibLoaderBase preloaded "+preload[i]);
}
- }
- catch (UnsatisfiedLinkError e) {
- if(DEBUG) e.printStackTrace();
+ } catch (UnsatisfiedLinkError e) {
+ if(DEBUG) {
+ e.printStackTrace();
+ }
if (!preloadIgnoreError && e.getMessage().indexOf("already loaded") < 0) {
throw e;
}
@@ -140,6 +140,7 @@ public class NativeLibLoaderBase {
private static final Class customLauncherClass;
private static final Method customLoadLibraryMethod;
+ // FIXME centralize logging
static {
Class launcherClass = null;
Method loadLibraryMethod = null;
@@ -148,12 +149,15 @@ public class NativeLibLoaderBase {
try {
launcherClass = Class.forName("org.jdesktop.applet.util.JNLPAppletLauncher");
loadLibraryMethod = launcherClass.getDeclaredMethod("loadLibrary", new Class[] { String.class });
- } catch (Throwable t) {
+ } catch (ClassNotFoundException ex) {
+ if(DEBUG) {
+ ex.printStackTrace();
+ }
+ } catch (NoSuchMethodException ex) {
if(DEBUG) {
- t.printStackTrace();
+ ex.printStackTrace();
}
launcherClass = null;
- loadLibraryMethod = null;
}
}
@@ -163,15 +167,19 @@ public class NativeLibLoaderBase {
try {
launcherClass = Class.forName(launcherClassName);
loadLibraryMethod = launcherClass.getDeclaredMethod("loadLibrary", new Class[] { String.class });
- } catch (Throwable t) {
+ } catch (ClassNotFoundException ex) {
+ if(DEBUG) {
+ ex.printStackTrace();
+ }
+ } catch (NoSuchMethodException ex) {
if(DEBUG) {
- t.printStackTrace();
+ ex.printStackTrace();
}
launcherClass = null;
- loadLibraryMethod = null;
}
}
}
+
customLauncherClass = launcherClass;
customLoadLibraryMethod = loadLibraryMethod;
}
@@ -192,7 +200,7 @@ public class NativeLibLoaderBase {
throw (RuntimeException) t;
}
// Throw UnsatisfiedLinkError for best compatibility with System.loadLibrary()
- throw (UnsatisfiedLinkError) new UnsatisfiedLinkError().initCause(e);
+ throw (UnsatisfiedLinkError)new UnsatisfiedLinkError("can not load library "+libraryName).initCause(e);
}
} else {
// System.out.println("sun.boot.library.path=" + Debug.getProperty("sun.boot.library.path", false));