aboutsummaryrefslogtreecommitdiffstats
path: root/src/java/jogamp/common/os
diff options
context:
space:
mode:
Diffstat (limited to 'src/java/jogamp/common/os')
-rw-r--r--src/java/jogamp/common/os/BionicDynamicLinkerImpl.java43
-rw-r--r--src/java/jogamp/common/os/MacOSXDynamicLinkerImpl.java41
-rw-r--r--src/java/jogamp/common/os/PosixDynamicLinkerImpl.java41
-rw-r--r--src/java/jogamp/common/os/UnixDynamicLinkerImpl.java22
4 files changed, 32 insertions, 115 deletions
diff --git a/src/java/jogamp/common/os/BionicDynamicLinkerImpl.java b/src/java/jogamp/common/os/BionicDynamicLinkerImpl.java
index 15d884f..453f200 100644
--- a/src/java/jogamp/common/os/BionicDynamicLinkerImpl.java
+++ b/src/java/jogamp/common/os/BionicDynamicLinkerImpl.java
@@ -27,8 +27,6 @@
*/
package jogamp.common.os;
-import com.jogamp.common.util.SecurityUtil;
-
/**
* Bionic specialization of {@link UnixDynamicLinkerImpl}
* utilizing Bionic's non POSIX flags and mode values.
@@ -47,50 +45,17 @@ public final class BionicDynamicLinkerImpl extends UnixDynamicLinkerImpl {
@Override
public final long openLibraryLocal(String pathname, boolean debug) throws SecurityException {
- // Note we use RTLD_GLOBAL visibility to _NOT_ allow this functionality to
- // be used to pre-resolve dependent libraries of JNI code without
- // requiring that all references to symbols in those libraries be
- // looked up dynamically via the ProcAddressTable mechanism; in
- // other words, one can actually link against the library instead of
- // having to dlsym all entry points. System.loadLibrary() uses
- // RTLD_LOCAL visibility so can't be used for this purpose.
- SecurityUtil.checkLinkPermission(pathname);
- final long handle = dlopen(pathname, RTLD_LAZY | RTLD_LOCAL);
- if( 0 != handle ) {
- incrLibRefCount(handle, pathname);
- } else if ( DEBUG || debug ) {
- System.err.println("dlopen \""+pathname+"\" local failed, error: "+dlerror());
- }
- return handle;
+ return this.openLibraryImpl(pathname, RTLD_LAZY | RTLD_LOCAL, debug);
}
@Override
public final long openLibraryGlobal(String pathname, boolean debug) throws SecurityException {
- // Note we use RTLD_GLOBAL visibility to allow this functionality to
- // be used to pre-resolve dependent libraries of JNI code without
- // requiring that all references to symbols in those libraries be
- // looked up dynamically via the ProcAddressTable mechanism; in
- // other words, one can actually link against the library instead of
- // having to dlsym all entry points. System.loadLibrary() uses
- // RTLD_LOCAL visibility so can't be used for this purpose.
- SecurityUtil.checkLinkPermission(pathname);
- final long handle = dlopen(pathname, RTLD_LAZY | RTLD_GLOBAL);
- if( 0 != handle ) {
- incrLibRefCount(handle, pathname);
- } else if ( DEBUG || debug ) {
- System.err.println("dlopen \""+pathname+"\" global failed, error: "+dlerror());
- }
- return handle;
+ return this.openLibraryImpl(pathname, RTLD_LAZY | RTLD_GLOBAL, debug);
}
@Override
- public final long lookupSymbolGlobal(String symbolName) throws SecurityException {
- SecurityUtil.checkAllLinkPermission();
- final long addr = dlsym(RTLD_DEFAULT, symbolName);
- if(DEBUG_LOOKUP) {
- System.err.println("DynamicLinkerImpl.lookupSymbolGlobal("+symbolName+") -> 0x"+Long.toHexString(addr));
- }
- return addr;
+ public final long lookupSymbolGlobal(String symbolName) throws SecurityException {
+ return this.lookupSymbolGlobalImpl(RTLD_DEFAULT, symbolName);
}
}
diff --git a/src/java/jogamp/common/os/MacOSXDynamicLinkerImpl.java b/src/java/jogamp/common/os/MacOSXDynamicLinkerImpl.java
index beab5d5..18dcf97 100644
--- a/src/java/jogamp/common/os/MacOSXDynamicLinkerImpl.java
+++ b/src/java/jogamp/common/os/MacOSXDynamicLinkerImpl.java
@@ -27,8 +27,6 @@
*/
package jogamp.common.os;
-import com.jogamp.common.util.SecurityUtil;
-
/**
* Mac OS X specialization of {@link UnixDynamicLinkerImpl}
* utilizing OS X 's non POSIX flags and mode values.
@@ -45,50 +43,17 @@ public final class MacOSXDynamicLinkerImpl extends UnixDynamicLinkerImpl {
@Override
public final long openLibraryLocal(String pathname, boolean debug) throws SecurityException {
- // Note we use RTLD_LOCAL visibility to _NOT_ allow this functionality to
- // be used to pre-resolve dependent libraries of JNI code without
- // requiring that all references to symbols in those libraries be
- // looked up dynamically via the ProcAddressTable mechanism; in
- // other words, one can actually link against the library instead of
- // having to dlsym all entry points. System.loadLibrary() uses
- // RTLD_LOCAL visibility so can't be used for this purpose.
- SecurityUtil.checkLinkPermission(pathname);
- final long handle = dlopen(pathname, RTLD_LAZY | RTLD_LOCAL);
- if( 0 != handle ) {
- incrLibRefCount(handle, pathname);
- } else if ( DEBUG || debug ) {
- System.err.println("dlopen \""+pathname+"\" local failed, error: "+dlerror());
- }
- return handle;
+ return this.openLibraryImpl(pathname, RTLD_LAZY | RTLD_LOCAL, debug);
}
@Override
public final long openLibraryGlobal(String pathname, boolean debug) throws SecurityException {
- // Note we use RTLD_GLOBAL visibility to allow this functionality to
- // be used to pre-resolve dependent libraries of JNI code without
- // requiring that all references to symbols in those libraries be
- // looked up dynamically via the ProcAddressTable mechanism; in
- // other words, one can actually link against the library instead of
- // having to dlsym all entry points. System.loadLibrary() uses
- // RTLD_LOCAL visibility so can't be used for this purpose.
- SecurityUtil.checkLinkPermission(pathname);
- final long handle = dlopen(pathname, RTLD_LAZY | RTLD_GLOBAL);
- if( 0 != handle ) {
- incrLibRefCount(handle, pathname);
- } else if ( DEBUG || debug ) {
- System.err.println("dlopen \""+pathname+"\" global failed, error: "+dlerror());
- }
- return handle;
+ return this.openLibraryImpl(pathname, RTLD_LAZY | RTLD_GLOBAL, debug);
}
@Override
public final long lookupSymbolGlobal(String symbolName) throws SecurityException {
- SecurityUtil.checkAllLinkPermission();
- final long addr = dlsym(RTLD_DEFAULT, symbolName);
- if(DEBUG_LOOKUP) {
- System.err.println("DynamicLinkerImpl.lookupSymbolGlobal("+symbolName+") -> 0x"+Long.toHexString(addr));
- }
- return addr;
+ return this.lookupSymbolGlobalImpl(RTLD_DEFAULT, symbolName);
}
}
diff --git a/src/java/jogamp/common/os/PosixDynamicLinkerImpl.java b/src/java/jogamp/common/os/PosixDynamicLinkerImpl.java
index 50feb94..fced97f 100644
--- a/src/java/jogamp/common/os/PosixDynamicLinkerImpl.java
+++ b/src/java/jogamp/common/os/PosixDynamicLinkerImpl.java
@@ -27,8 +27,6 @@
*/
package jogamp.common.os;
-import com.jogamp.common.util.SecurityUtil;
-
public final class PosixDynamicLinkerImpl extends UnixDynamicLinkerImpl {
private static final long RTLD_DEFAULT = 0;
@@ -41,49 +39,16 @@ public final class PosixDynamicLinkerImpl extends UnixDynamicLinkerImpl {
@Override
public final long openLibraryLocal(String pathname, boolean debug) throws SecurityException {
- // Note we use RTLD_GLOBAL visibility to _NOT_ allow this functionality to
- // be used to pre-resolve dependent libraries of JNI code without
- // requiring that all references to symbols in those libraries be
- // looked up dynamically via the ProcAddressTable mechanism; in
- // other words, one can actually link against the library instead of
- // having to dlsym all entry points. System.loadLibrary() uses
- // RTLD_LOCAL visibility so can't be used for this purpose.
- SecurityUtil.checkLinkPermission(pathname);
- final long handle = dlopen(pathname, RTLD_LAZY | RTLD_LOCAL);
- if( 0 != handle ) {
- incrLibRefCount(handle, pathname);
- } else if ( DEBUG || debug ) {
- System.err.println("dlopen \""+pathname+"\" local failed, error: "+dlerror());
- }
- return handle;
+ return this.openLibraryImpl(pathname, RTLD_LAZY | RTLD_LOCAL, debug);
}
@Override
public final long openLibraryGlobal(String pathname, boolean debug) throws SecurityException {
- // Note we use RTLD_GLOBAL visibility to allow this functionality to
- // be used to pre-resolve dependent libraries of JNI code without
- // requiring that all references to symbols in those libraries be
- // looked up dynamically via the ProcAddressTable mechanism; in
- // other words, one can actually link against the library instead of
- // having to dlsym all entry points. System.loadLibrary() uses
- // RTLD_LOCAL visibility so can't be used for this purpose.
- SecurityUtil.checkLinkPermission(pathname);
- final long handle = dlopen(pathname, RTLD_LAZY | RTLD_GLOBAL);
- if( 0 != handle ) {
- incrLibRefCount(handle, pathname);
- } else if ( DEBUG || debug ) {
- System.err.println("dlopen \""+pathname+"\" global failed, error: "+dlerror());
- }
- return handle;
+ return this.openLibraryImpl(pathname, RTLD_LAZY | RTLD_GLOBAL, debug);
}
@Override
public final long lookupSymbolGlobal(String symbolName) throws SecurityException {
- SecurityUtil.checkAllLinkPermission();
- final long addr = dlsym(RTLD_DEFAULT, symbolName);
- if(DEBUG_LOOKUP) {
- System.err.println("DynamicLinkerImpl.lookupSymbolGlobal("+symbolName+") -> 0x"+Long.toHexString(addr));
- }
- return addr;
+ return this.lookupSymbolGlobalImpl(RTLD_DEFAULT, symbolName);
}
}
diff --git a/src/java/jogamp/common/os/UnixDynamicLinkerImpl.java b/src/java/jogamp/common/os/UnixDynamicLinkerImpl.java
index 25f4072..7f10d8a 100644
--- a/src/java/jogamp/common/os/UnixDynamicLinkerImpl.java
+++ b/src/java/jogamp/common/os/UnixDynamicLinkerImpl.java
@@ -27,6 +27,8 @@
*/
package jogamp.common.os;
+import com.jogamp.common.util.SecurityUtil;
+
/* pp */ abstract class UnixDynamicLinkerImpl extends DynamicLinkerImpl {
//
@@ -47,6 +49,26 @@ package jogamp.common.os;
/** Interface to C language function: <br> <code> void * dlsym(void * , const char * ); </code> */
protected static native long dlsym(long arg0, java.lang.String arg1);
+ protected final long openLibraryImpl(String pathname, int dlSymFlags, boolean debug) throws SecurityException {
+ SecurityUtil.checkLinkPermission(pathname);
+ final long handle = dlopen(pathname, dlSymFlags);
+ if( 0 != handle ) {
+ incrLibRefCount(handle, pathname);
+ } else if ( DEBUG || debug ) {
+ System.err.println("dlopen \""+pathname+"\" failed, error: "+dlerror());
+ }
+ return handle;
+ }
+
+ protected final long lookupSymbolGlobalImpl(long dlSymGlobalFlag, String symbolName) throws SecurityException {
+ SecurityUtil.checkAllLinkPermission();
+ final long addr = dlsym(dlSymGlobalFlag, symbolName);
+ if(DEBUG_LOOKUP) {
+ System.err.println("DynamicLinkerImpl.lookupSymbolGlobal("+symbolName+") -> 0x"+Long.toHexString(addr));
+ }
+ return addr;
+ }
+
@Override
public final long lookupSymbol(long libraryHandle, String symbolName) throws IllegalArgumentException {
if( null == getLibRef( libraryHandle ) ) {