summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorSven Gothel <[email protected]>2011-09-23 15:35:38 +0200
committerSven Gothel <[email protected]>2011-09-23 15:35:38 +0200
commitc8cd39fbe077ebf0a4785750752135f26e4a94ab (patch)
tree3292360447fcfcf460acfa196214d5a0d1c407be
parent609e649443f900116039cda7a1bc7c9359b0242f (diff)
Better DEBUG output
-rw-r--r--src/java/com/jogamp/common/jvm/JNILibLoaderBase.java16
-rw-r--r--src/java/com/jogamp/common/util/JarUtil.java45
-rw-r--r--src/java/com/jogamp/common/util/cache/TempFileCache.java61
3 files changed, 62 insertions, 60 deletions
diff --git a/src/java/com/jogamp/common/jvm/JNILibLoaderBase.java b/src/java/com/jogamp/common/jvm/JNILibLoaderBase.java
index bb0860a..348fb54 100644
--- a/src/java/com/jogamp/common/jvm/JNILibLoaderBase.java
+++ b/src/java/com/jogamp/common/jvm/JNILibLoaderBase.java
@@ -87,7 +87,7 @@ public class JNILibLoaderBase {
loadLibraryInternal(libname);
addLoaded(libname);
if(DEBUG) {
- System.err.println("JNILibLoaderBase loaded "+libname);
+ System.err.println("JNILibLoaderBase: loaded "+libname);
}
} catch (UnsatisfiedLinkError e) {
res = false;
@@ -124,7 +124,7 @@ public class JNILibLoaderBase {
public static void addLoaded(String libName) {
loaded.add(libName);
if(DEBUG) {
- System.err.println("JNILibLoaderBase Loaded Native Library: "+libName);
+ System.err.println("JNILibLoaderBase: Loaded Native Library: "+libName);
}
}
@@ -147,15 +147,15 @@ public class JNILibLoaderBase {
try {
URL jarUrlRoot = JarUtil.getJarURLDirname( JarUtil.getJarURL( classFromJavaJar.getName(), cl ) );
if(DEBUG) {
- System.err.println("addNativeJarLibs: "+nativeJarBaseName+": url-root "+jarUrlRoot);
+ System.err.println("JNILibLoaderBase: addNativeJarLibs: "+nativeJarBaseName+": url-root "+jarUrlRoot);
}
URL nativeJarURL = JarUtil.getJarURL(jarUrlRoot, nativeJarName);
if(DEBUG) {
- System.err.println("addNativeJarLibs: "+nativeJarBaseName+": nativeJarURL "+nativeJarURL);
+ System.err.println("JNILibLoaderBase: addNativeJarLibs: "+nativeJarBaseName+": nativeJarURL "+nativeJarURL);
}
JarFile nativeJar = JarUtil.getJarFile(nativeJarURL, cl);
if(DEBUG) {
- System.err.println("addNativeJarLibs: "+nativeJarBaseName+": nativeJar "+nativeJar.getName());
+ System.err.println("JNILibLoaderBase: addNativeJarLibs: "+nativeJarBaseName+": nativeJar "+nativeJar.getName());
}
return TempJarCache.addNativeLibs(classFromJavaJar, nativeJar);
} catch (IOException ioe) {
@@ -258,17 +258,17 @@ public class JNILibLoaderBase {
final String fullLibraryName = TempJarCache.findLibrary(libraryName);
if(null != fullLibraryName) {
if(DEBUG) {
- System.err.println("JNILibLoaderBase.loadLibraryInternal("+libraryName+") -> System.load("+fullLibraryName+") (TempJarCache)");
+ System.err.println("JNILibLoaderBase: loadLibraryInternal("+libraryName+") -> System.load("+fullLibraryName+") (TempJarCache)");
}
System.load(fullLibraryName);
return; // done
} else if(DEBUG) {
- System.err.println("JNILibLoaderBase.loadLibraryInternal("+libraryName+") -> TempJarCache not mapped");
+ System.err.println("JNILibLoaderBase: loadLibraryInternal("+libraryName+") -> TempJarCache not mapped");
}
}
// System.err.println("sun.boot.library.path=" + Debug.getProperty("sun.boot.library.path", false));
if(DEBUG) {
- System.err.println("JNILibLoaderBase.loadLibraryInternal("+libraryName+") -> System.loadLibrary("+libraryName+")");
+ System.err.println("JNILibLoaderBase: loadLibraryInternal("+libraryName+") -> System.loadLibrary("+libraryName+")");
}
System.loadLibrary(libraryName);
}
diff --git a/src/java/com/jogamp/common/util/JarUtil.java b/src/java/com/jogamp/common/util/JarUtil.java
index 4f46ca8..c95ad29 100644
--- a/src/java/com/jogamp/common/util/JarUtil.java
+++ b/src/java/com/jogamp/common/util/JarUtil.java
@@ -37,7 +37,6 @@ import java.io.OutputStream;
import java.net.JarURLConnection;
import java.net.URL;
import java.net.URLConnection;
-import java.security.AccessController;
import java.security.cert.Certificate;
import java.util.Enumeration;
import java.util.HashMap;
@@ -50,7 +49,7 @@ import com.jogamp.common.os.NativeLibrary;
import jogamp.common.Debug;
public class JarUtil {
- private static final boolean VERBOSE = Debug.isPropertyDefined("jogamp.debug.JARUtil", true, AccessController.getContext());
+ private static final boolean DEBUG = Debug.debug("JarUtil");
/**
* @param clazzBinName com.jogamp.common.util.cache.TempJarCache
@@ -162,8 +161,8 @@ public class JarUtil {
* Return a map from native-lib-base-name to entry-name.
*/
public static Map<String, String> getNativeLibNames(JarFile jarFile) {
- if (VERBOSE) {
- System.err.println("getNativeLibNames: "+jarFile);
+ if (DEBUG) {
+ System.err.println("JarUtil: getNativeLibNames: "+jarFile);
}
Map<String,String> nameMap = new HashMap<String, String>();
@@ -222,8 +221,8 @@ public class JarUtil {
boolean extractClassFiles,
boolean extractOtherFiles) throws IOException {
- if (VERBOSE) {
- System.err.println("extract: "+jarFile.getName()+" -> "+dest+
+ if (DEBUG) {
+ System.err.println("JarUtil: extract: "+jarFile.getName()+" -> "+dest+
", extractNativeLibraries "+extractNativeLibraries+
", extractClassFiles"+extractClassFiles+
", extractOtherFiles "+extractOtherFiles);
@@ -239,23 +238,23 @@ public class JarUtil {
final String libBaseName = NativeLibrary.isValidNativeLibraryName(entryName, false);
final boolean isNativeLib = null != libBaseName;
if(isNativeLib && !extractNativeLibraries) {
- if (VERBOSE) {
- System.err.println("JarEntry : " + entryName + " native-lib skipped");
+ if (DEBUG) {
+ System.err.println("JarUtil: JarEntry : " + entryName + " native-lib skipped");
}
continue;
}
final boolean isClassFile = entryName.endsWith(".class");
if(isClassFile && !extractClassFiles) {
- if (VERBOSE) {
- System.err.println("JarEntry : " + entryName + " class-file skipped");
+ if (DEBUG) {
+ System.err.println("JarUtil: JarEntry : " + entryName + " class-file skipped");
}
continue;
}
if(!isNativeLib && !isClassFile && !extractOtherFiles) {
- if (VERBOSE) {
- System.err.println("JarEntry : " + entryName + " other-file skipped");
+ if (DEBUG) {
+ System.err.println("JarUtil: JarEntry : " + entryName + " other-file skipped");
}
continue;
}
@@ -268,8 +267,8 @@ public class JarUtil {
final File destFile = new File(dest, entryName);
if(isDir) {
destFile.mkdir();
- if (VERBOSE) {
- System.err.println("MKDIR: " + entryName + " -> " + destFile );
+ if (DEBUG) {
+ System.err.println("JarUtil: MKDIR: " + entryName + " -> " + destFile );
}
} else {
final InputStream in = new BufferedInputStream(jarFile.getInputStream(entry));
@@ -289,8 +288,8 @@ public class JarUtil {
addedAsNativeLib = true;
}
}
- if (VERBOSE) {
- System.err.println("EXTRACT["+num+"]: [" + libBaseName + " -> ] " + entryName + " -> " + destFile + ": "+numBytes+" bytes, addedAsNativeLib: "+addedAsNativeLib);
+ if (DEBUG) {
+ System.err.println("JarUtil: EXTRACT["+num+"]: [" + libBaseName + " -> ] " + entryName + " -> " + destFile + ": "+numBytes+" bytes, addedAsNativeLib: "+addedAsNativeLib);
}
}
}
@@ -308,8 +307,8 @@ public class JarUtil {
public static final void validateCertificates(Certificate[] rootCerts, JarFile jarFile)
throws IOException, SecurityException {
- if (VERBOSE) {
- System.err.println("validateCertificates: "+jarFile.getName());
+ if (DEBUG) {
+ System.err.println("JarUtil: validateCertificates: "+jarFile.getName());
}
if (rootCerts == null || rootCerts.length == 0) {
@@ -319,7 +318,11 @@ public class JarUtil {
byte[] buf = new byte[1024];
Enumeration<JarEntry> entries = jarFile.entries();
while (entries.hasMoreElements()) {
- validateCertificate(rootCerts, jarFile, entries.nextElement(), buf);
+ final JarEntry entry = entries.nextElement();
+ if( ! entry.isDirectory() && ! entry.getName().startsWith("META-INF/") ) {
+ // only validate non META-INF and non directories
+ validateCertificate(rootCerts, jarFile, entry, buf);
+ }
}
}
@@ -330,8 +333,8 @@ public class JarUtil {
private static final void validateCertificate(Certificate[] rootCerts,
JarFile jar, JarEntry entry, byte[] buf) throws IOException, SecurityException {
- if (VERBOSE) {
- System.err.println("Validate JarEntry : " + entry.getName());
+ if (DEBUG) {
+ System.err.println("JarUtil: validate JarEntry : " + entry.getName());
}
// API states that we must read all of the data from the entry's
diff --git a/src/java/com/jogamp/common/util/cache/TempFileCache.java b/src/java/com/jogamp/common/util/cache/TempFileCache.java
index ef5a2a2..a4cb2f4 100644
--- a/src/java/com/jogamp/common/util/cache/TempFileCache.java
+++ b/src/java/com/jogamp/common/util/cache/TempFileCache.java
@@ -33,12 +33,11 @@ import java.io.FilenameFilter;
import java.io.IOException;
import java.nio.channels.FileChannel;
import java.nio.channels.FileLock;
-import java.security.AccessController;
import jogamp.common.Debug;
public class TempFileCache {
- private static final boolean VERBOSE = Debug.isPropertyDefined("jogamp.debug.TempFileCache", true, AccessController.getContext());
+ private static final boolean DEBUG = Debug.debug("TempFileCache");
// Lifecycle: For all JVMs, ClassLoader and times.
private static final String tmpDirPrefix = "jogamp.tmp.cache";
@@ -136,9 +135,9 @@ public class TempFileCache {
* 6. Start the Reaper thread to cleanup old installations.
*/
private static void initTmpRoot() throws IOException {
- if (VERBOSE) {
- System.err.println("TempFileCache Static Initialization ----------------------------------------------");
- System.err.println("Thread: "+Thread.currentThread().getName()+", CL 0x"+Integer.toHexString(TempFileCache.class.getClassLoader().hashCode()));
+ if (DEBUG) {
+ System.err.println("TempFileCache: Static Initialization ----------------------------------------------");
+ System.err.println("TempFileCache: Thread: "+Thread.currentThread().getName()+", CL 0x"+Integer.toHexString(TempFileCache.class.getClassLoader().hashCode()));
}
synchronized (System.out) {
@@ -158,8 +157,8 @@ public class TempFileCache {
// Create ${tmpbase}/jlnNNNN.tmp then lock the file
File tmpFile = File.createTempFile("jln", ".tmp", tmpBaseDir);
- if (VERBOSE) {
- System.err.println("tmpFile = " + tmpFile.getAbsolutePath());
+ if (DEBUG) {
+ System.err.println("TempFileCache: tmpFile = " + tmpFile.getAbsolutePath());
}
final FileOutputStream tmpOut = new FileOutputStream(tmpFile);
final FileChannel tmpChannel = tmpOut.getChannel();
@@ -172,8 +171,8 @@ public class TempFileCache {
// create ${tmpbase}/jlnNNNN.lck then lock the file
String lckFileName = tmpRootName + ".lck";
File lckFile = new File(lckFileName);
- if (VERBOSE) {
- System.err.println("lckFile = " + lckFile.getAbsolutePath());
+ if (DEBUG) {
+ System.err.println("TempFileCache: lckFile = " + lckFile.getAbsolutePath());
}
lckFile.createNewFile();
final FileOutputStream lckOut = new FileOutputStream(lckFile);
@@ -182,8 +181,8 @@ public class TempFileCache {
// Create tmprootdir
tmpRootDir = new File(tmpRootName);
- if (VERBOSE) {
- System.err.println("tmpRootDir = " + tmpRootDir.getAbsolutePath());
+ if (DEBUG) {
+ System.err.println("TempFileCache: tmpRootDir = " + tmpRootDir.getAbsolutePath());
}
if (!tmpRootDir.mkdir()) {
throw new IOException("Cannot create " + tmpRootDir);
@@ -213,8 +212,8 @@ public class TempFileCache {
// Set the system property...
tmpRootPropValue = tmpRootName.substring(tmpRootName.lastIndexOf(File.separator) + 1);
System.setProperty(tmpRootPropName, tmpRootPropValue);
- if (VERBOSE) {
- System.err.println("Setting " + tmpRootPropName + "=" + tmpRootPropValue);
+ if (DEBUG) {
+ System.err.println("TempFileCache: Setting " + tmpRootPropName + "=" + tmpRootPropValue);
}
// Start a new Reaper thread to do stuff...
@@ -234,20 +233,20 @@ public class TempFileCache {
}
// Set tmpRootDir = ${tmpbase}/${jnlp.applet.launcher.tmproot}
- if (VERBOSE) {
- System.err.println("Using existing value of: " +
+ if (DEBUG) {
+ System.err.println("TempFileCache: Using existing value of: " +
tmpRootPropName + "=" + tmpRootPropValue);
}
tmpRootDir = new File(tmpBaseDir, tmpRootPropValue);
- if (VERBOSE) {
- System.err.println("tmpRootDir = " + tmpRootDir.getAbsolutePath());
+ if (DEBUG) {
+ System.err.println("TempFileCache: tmpRootDir = " + tmpRootDir.getAbsolutePath());
}
if (!tmpRootDir.isDirectory()) {
throw new IOException("Cannot access " + tmpRootDir);
}
}
}
- if (VERBOSE) {
+ if (DEBUG) {
System.err.println("------------------------------------------------------------------ (static ok: "+(!staticInitError)+")");
}
}
@@ -257,8 +256,8 @@ public class TempFileCache {
* Only one of these threads will run per JVM invocation.
*/
private static void deleteOldTempDirs() {
- if (VERBOSE) {
- System.err.println("*** Reaper: deleteOldTempDirs in " +
+ if (DEBUG) {
+ System.err.println("TempFileCache: *** Reaper: deleteOldTempDirs in " +
tmpBaseDir.getAbsolutePath());
}
@@ -298,7 +297,7 @@ public class TempFileCache {
tmpLock = tmpChannel.tryLock();
} catch (Exception ex) {
// Ignore exceptions
- if (VERBOSE) {
+ if (DEBUG) {
ex.printStackTrace();
}
}
@@ -313,7 +312,7 @@ public class TempFileCache {
lckChannel = lckOut.getChannel();
lckLock = lckChannel.tryLock();
} catch (Exception ex) {
- if (VERBOSE) {
+ if (DEBUG) {
ex.printStackTrace();
}
}
@@ -351,15 +350,15 @@ public class TempFileCache {
tmpOut.close();
tmpLock.release();
} catch (IOException ex) {
- if (VERBOSE) {
+ if (DEBUG) {
ex.printStackTrace();
}
}
}
}
} else {
- if (VERBOSE) {
- System.err.println(" Skipping: " + tmpDir.getAbsolutePath());
+ if (DEBUG) {
+ System.err.println("TempFileCache: Skipping: " + tmpDir.getAbsolutePath());
}
}
}
@@ -371,8 +370,8 @@ public class TempFileCache {
* recursively remove all entries, then remove the directory itself.
*/
private static void removeAll(File path) {
- if (VERBOSE) {
- System.err.println("removeAll(" + path + ")");
+ if (DEBUG) {
+ System.err.println("TempFileCache: removeAll(" + path + ")");
}
if (path.isDirectory()) {
@@ -389,9 +388,9 @@ public class TempFileCache {
}
public TempFileCache () {
- if (VERBOSE) {
- System.err.println("new TempFileCache() --------------------- (static ok: "+(!staticInitError)+")");
- System.err.println("Thread: "+Thread.currentThread().getName()+", CL 0x"+Integer.toHexString(TempFileCache.class.getClassLoader().hashCode())+", this 0x"+Integer.toHexString(hashCode()));
+ if (DEBUG) {
+ System.err.println("TempFileCache: new TempFileCache() --------------------- (static ok: "+(!staticInitError)+")");
+ System.err.println("TempFileCache: Thread: "+Thread.currentThread().getName()+", CL 0x"+Integer.toHexString(TempFileCache.class.getClassLoader().hashCode())+", this 0x"+Integer.toHexString(hashCode()));
}
if(!staticInitError) {
try {
@@ -401,7 +400,7 @@ public class TempFileCache {
initError = true;
}
}
- if (VERBOSE) {
+ if (DEBUG) {
System.err.println("tempDir: "+individualTmpDir+" (ok: "+(!initError)+")");
System.err.println("----------------------------------------------------------");
}