From bd5be69aee6987754f1cbf39f61280c5c72536b3 Mon Sep 17 00:00:00 2001 From: Sven Gothel Date: Sun, 12 Feb 2012 06:06:59 +0100 Subject: 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 --- .../com/jogamp/common/os/DynamicLibraryBundle.java | 48 ++++++++++------------ src/java/com/jogamp/common/os/DynamicLinker.java | 3 ++ .../com/jogamp/common/os/DynamicLookupHelper.java | 5 +++ src/java/com/jogamp/common/os/NativeLibrary.java | 5 +-- 4 files changed, 31 insertions(+), 30 deletions(-) (limited to 'src/java/com') 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; * */ 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> toolLibNames; @@ -68,6 +65,7 @@ public class DynamicLibraryBundle implements DynamicLookupHelper { private int glueLibLoadedNumber; private long toolGetProcAddressHandle; + private boolean toolGetProcAddressComplete; private HashSet toolGetProcAddressFuncNameSet; private List 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(toolGetProcAddressFuncNameList); toolGetProcAddressHandle = getToolGetProcAddressHandle(); + toolGetProcAddressComplete = 0 != toolGetProcAddressHandle; } else { toolGetProcAddressFuncNameSet = new HashSet(); 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=0; i--) { toolLibLoaded[i] = false; } - glueLibLoaded = new boolean[glueLibNames.size()]; - for(i=0; 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; -- cgit v1.2.3