summaryrefslogtreecommitdiffstats
path: root/src/java/com/jogamp/common
diff options
context:
space:
mode:
authorSven Gothel <[email protected]>2012-02-12 06:06:59 +0100
committerSven Gothel <[email protected]>2012-02-12 06:06:59 +0100
commitbd5be69aee6987754f1cbf39f61280c5c72536b3 (patch)
treeb6894cbc2bc6e659ac0d921a9c50ff664269faac /src/java/com/jogamp/common
parent67854df4b16ce92d0e792f3c693ced0a6470f6cc (diff)
DynamicLibraryBundle (enhancement)
- Hold DEBUG, DEBUG_LOOKUP in DynamicLookupHelper - Tool complete only if named tool's GetProcAddressFunc is avail - Allow no tool/glue lib's - Use DEBUG_LOCKUP for lockup symbol trace
Diffstat (limited to 'src/java/com/jogamp/common')
-rwxr-xr-xsrc/java/com/jogamp/common/os/DynamicLibraryBundle.java48
-rwxr-xr-xsrc/java/com/jogamp/common/os/DynamicLinker.java3
-rwxr-xr-xsrc/java/com/jogamp/common/os/DynamicLookupHelper.java5
-rwxr-xr-xsrc/java/com/jogamp/common/os/NativeLibrary.java5
4 files changed, 31 insertions, 30 deletions
diff --git a/src/java/com/jogamp/common/os/DynamicLibraryBundle.java b/src/java/com/jogamp/common/os/DynamicLibraryBundle.java
index c8bf30a..8a71123 100755
--- a/src/java/com/jogamp/common/os/DynamicLibraryBundle.java
+++ b/src/java/com/jogamp/common/os/DynamicLibraryBundle.java
@@ -53,9 +53,6 @@ import com.jogamp.common.jvm.JNILibLoaderBase;
* </ul>
*/
public class DynamicLibraryBundle implements DynamicLookupHelper {
- protected static final boolean DEBUG = NativeLibrary.DEBUG;
- protected static final boolean DEBUG_LOOKUP = NativeLibrary.DEBUG_LOOKUP;
-
private DynamicLibraryBundleInfo info;
private List<List<String>> toolLibNames;
@@ -68,6 +65,7 @@ public class DynamicLibraryBundle implements DynamicLookupHelper {
private int glueLibLoadedNumber;
private long toolGetProcAddressHandle;
+ private boolean toolGetProcAddressComplete;
private HashSet<String> toolGetProcAddressFuncNameSet;
private List<String> toolGetProcAddressFuncNameList;
@@ -86,16 +84,18 @@ public class DynamicLibraryBundle implements DynamicLookupHelper {
glueLibNames = info.getGlueLibNames();
loadLibraries();
toolGetProcAddressFuncNameList = info.getToolGetProcAddressFuncNameList();
- if(null!=toolGetProcAddressFuncNameList) {
+ if( null != toolGetProcAddressFuncNameList ) {
toolGetProcAddressFuncNameSet = new HashSet<String>(toolGetProcAddressFuncNameList);
toolGetProcAddressHandle = getToolGetProcAddressHandle();
+ toolGetProcAddressComplete = 0 != toolGetProcAddressHandle;
} else {
toolGetProcAddressFuncNameSet = new HashSet<String>();
toolGetProcAddressHandle = 0;
+ toolGetProcAddressComplete = true;
}
if(DEBUG) {
System.err.println("DynamicLibraryBundle.init Summary: "+info.getClass().getName());
- System.err.println(" toolGetProcAddressFuncNameList: "+toolGetProcAddressFuncNameList);
+ System.err.println(" toolGetProcAddressFuncNameList: "+toolGetProcAddressFuncNameList+", complete: "+toolGetProcAddressComplete+", 0x"+Long.toHexString(toolGetProcAddressHandle));
System.err.println(" Tool Lib Names : "+toolLibNames);
System.err.println(" Tool Lib Loaded: "+getToolLibLoadedNumber()+"/"+getToolLibNumber()+" "+Arrays.toString(toolLibLoaded)+", complete "+isToolLibComplete());
System.err.println(" Glue Lib Names : "+glueLibNames);
@@ -111,6 +111,7 @@ public class DynamicLibraryBundle implements DynamicLookupHelper {
}
toolGetProcAddressFuncNameSet = null;
toolGetProcAddressHandle = 0;
+ toolGetProcAddressComplete = false;
for(int i = 0; i<nativeLibraries.size(); i++) {
nativeLibraries.get(i).close();
}
@@ -143,7 +144,7 @@ public class DynamicLibraryBundle implements DynamicLookupHelper {
* @see DynamicLibraryBundleInfo#getToolLibNames()
*/
public final boolean isToolLibComplete() {
- return getToolLibNumber() == getToolLibLoadedNumber();
+ return toolGetProcAddressComplete && getToolLibNumber() == getToolLibLoadedNumber();
}
public final boolean isToolLibLoaded() {
@@ -173,7 +174,7 @@ public class DynamicLibraryBundle implements DynamicLookupHelper {
* @see DynamicLibraryBundleInfo#getGlueLibNames()
*/
public final boolean isGlueLibComplete() {
- return isGlueLibLoaded(getGlueLibNumber() - 1);
+ return 0 == getGlueLibNumber() || isGlueLibLoaded(getGlueLibNumber() - 1);
}
public final boolean isGlueLibLoaded(int i) {
@@ -211,32 +212,27 @@ public class DynamicLibraryBundle implements DynamicLookupHelper {
}
private void loadLibraries() {
- if( null == toolLibNames || toolLibNames.size() == 0) {
- if(DEBUG) {
- System.err.println("No Tool native library names given");
- }
- return;
- }
-
- if( null == glueLibNames || glueLibNames.size() == 0 ) {
- if(DEBUG) {
- System.err.println("No Glue native library names given");
- }
- return;
- }
-
- toolLibLoadedNumber = 0;
int i;
toolLibLoaded = new boolean[toolLibNames.size()];
- for(i=0; i<toolLibNames.size(); i++) {
+ for(i=toolLibNames.size()-1; i>=0; i--) {
toolLibLoaded[i] = false;
}
-
glueLibLoaded = new boolean[glueLibNames.size()];
- for(i=0; i<glueLibNames.size(); i++) {
+ for(i=glueLibNames.size()-1; i>=0; i--) {
glueLibLoaded[i] = false;
}
+
+ if(DEBUG) {
+ if( toolLibNames.size() == 0 ) {
+ System.err.println("No Tool native library names given");
+ }
+
+ if( glueLibNames.size() == 0 ) {
+ System.err.println("No Glue native library names given");
+ }
+ }
+ toolLibLoadedNumber = 0;
ClassLoader loader = getClass().getClassLoader();
NativeLibrary lib = null;
@@ -258,7 +254,7 @@ public class DynamicLibraryBundle implements DynamicLookupHelper {
}
}
}
- if( !isToolLibLoaded() ) {
+ if( toolLibNames.size() > 0 && !isToolLibLoaded() ) {
if(DEBUG) {
System.err.println("No Tool libraries loaded");
}
diff --git a/src/java/com/jogamp/common/os/DynamicLinker.java b/src/java/com/jogamp/common/os/DynamicLinker.java
index 924a776..a0da9fb 100755
--- a/src/java/com/jogamp/common/os/DynamicLinker.java
+++ b/src/java/com/jogamp/common/os/DynamicLinker.java
@@ -43,6 +43,9 @@ package com.jogamp.common.os;
linking functionality. */
public interface DynamicLinker {
+ public static final boolean DEBUG = NativeLibrary.DEBUG;
+ public static final boolean DEBUG_LOOKUP = NativeLibrary.DEBUG_LOOKUP;
+
public long openLibraryGlobal(String pathname, boolean debug);
public long openLibraryLocal(String pathname, boolean debug);
public long lookupSymbol(long libraryHandle, String symbolName);
diff --git a/src/java/com/jogamp/common/os/DynamicLookupHelper.java b/src/java/com/jogamp/common/os/DynamicLookupHelper.java
index 9c343d5..20fd01e 100755
--- a/src/java/com/jogamp/common/os/DynamicLookupHelper.java
+++ b/src/java/com/jogamp/common/os/DynamicLookupHelper.java
@@ -39,12 +39,17 @@
package com.jogamp.common.os;
+import jogamp.common.Debug;
+
/** Interface callers may use ProcAddressHelper's
* {@link com.jogamp.gluegen.runtime.ProcAddressTable#reset(com.jogamp.common.os.DynamicLookupHelper) reset}
* helper method to install function pointers into a
* ProcAddressTable. This must typically be written with native
* code. */
public interface DynamicLookupHelper {
+ public static final boolean DEBUG = Debug.debug("NativeLibrary");
+ public static final boolean DEBUG_LOOKUP = Debug.debug("NativeLibrary.Lookup");
+
/**
* Try to fetch the function pointer for function 'funcName'.
*/
diff --git a/src/java/com/jogamp/common/os/NativeLibrary.java b/src/java/com/jogamp/common/os/NativeLibrary.java
index b74f30d..69d69b6 100755
--- a/src/java/com/jogamp/common/os/NativeLibrary.java
+++ b/src/java/com/jogamp/common/os/NativeLibrary.java
@@ -41,7 +41,6 @@
package com.jogamp.common.os;
import com.jogamp.common.util.IOUtil;
-import jogamp.common.Debug;
import jogamp.common.os.MacOSXDynamicLinkerImpl;
import jogamp.common.os.UnixDynamicLinkerImpl;
import jogamp.common.os.WindowsDynamicLinkerImpl;
@@ -64,9 +63,7 @@ import java.util.*;
ProcAddressTable glue code generation style without additional
supporting code needed in the generated library. */
-public class NativeLibrary implements DynamicLookupHelper {
- protected static final boolean DEBUG = Debug.debug("NativeLibrary");
- protected static final boolean DEBUG_LOOKUP = Debug.debug("NativeLibrary.Lookup");
+public class NativeLibrary implements DynamicLookupHelper {
private static DynamicLinker dynLink;
private static String[] prefixes;
private static String[] suffixes;