summaryrefslogtreecommitdiffstats
path: root/src/java/com/sun/gluegen/runtime
diff options
context:
space:
mode:
authorKenneth Russel <[email protected]>2006-12-22 00:35:57 +0000
committerKenneth Russel <[email protected]>2006-12-22 00:35:57 +0000
commit7312c3822cd8538df108279b22e122a3c50032f7 (patch)
treebbe8bd47789d0905f40e18dde3062a28207a4669 /src/java/com/sun/gluegen/runtime
parent38c37a5afd42467108c2a37c5a00603da6df72db (diff)
Fixed latent problem with lookup of native libraries using ClassLoader
git-svn-id: file:///usr/local/projects/SUN/JOGL/git-svn/../svn-server-sync/gluegen/trunk@54 a78bb65f-1512-4460-ba86-f6dc96a7bf27
Diffstat (limited to 'src/java/com/sun/gluegen/runtime')
-rwxr-xr-xsrc/java/com/sun/gluegen/runtime/NativeLibrary.java18
1 files changed, 16 insertions, 2 deletions
diff --git a/src/java/com/sun/gluegen/runtime/NativeLibrary.java b/src/java/com/sun/gluegen/runtime/NativeLibrary.java
index 8ff28d3..9b28da4 100755
--- a/src/java/com/sun/gluegen/runtime/NativeLibrary.java
+++ b/src/java/com/sun/gluegen/runtime/NativeLibrary.java
@@ -241,6 +241,9 @@ public class NativeLibrary {
// The idea to ask the ClassLoader to find the library is borrowed
// from the LWJGL library
String clPath = getPathFromClassLoader(libName, loader);
+ if (DEBUG) {
+ System.out.println("Class loader path to " + libName + ": " + clPath);
+ }
if (clPath != null) {
paths.add(clPath);
}
@@ -321,7 +324,7 @@ public class NativeLibrary {
private static boolean initializedFindLibraryMethod = false;
private static Method findLibraryMethod = null;
- private static String getPathFromClassLoader(final String libName, ClassLoader loader) {
+ private static String getPathFromClassLoader(final String libName, final ClassLoader loader) {
if (loader == null)
return null;
if (!initializedFindLibraryMethod) {
@@ -341,8 +344,19 @@ public class NativeLibrary {
}
if (findLibraryMethod != null) {
try {
- return (String) findLibraryMethod.invoke(loader, new Object[] { libName });
+ return (String) AccessController.doPrivileged(new PrivilegedAction() {
+ public Object run() {
+ try {
+ return findLibraryMethod.invoke(loader, new Object[] { libName });
+ } catch (Exception e) {
+ throw new RuntimeException(e);
+ }
+ }
+ });
} catch (Exception e) {
+ if (DEBUG) {
+ e.printStackTrace();
+ }
// Fail silently and continue with other search algorithms
}
}