diff options
Diffstat (limited to 'src/java/com')
-rw-r--r-- | src/java/com/jogamp/common/ExceptionUtils.java | 25 | ||||
-rw-r--r-- | src/java/com/jogamp/common/os/NativeLibrary.java | 3 | ||||
-rw-r--r-- | src/java/com/jogamp/common/util/ReflectionUtil.java | 3 |
3 files changed, 21 insertions, 10 deletions
diff --git a/src/java/com/jogamp/common/ExceptionUtils.java b/src/java/com/jogamp/common/ExceptionUtils.java index 5829298..598cc61 100644 --- a/src/java/com/jogamp/common/ExceptionUtils.java +++ b/src/java/com/jogamp/common/ExceptionUtils.java @@ -33,28 +33,37 @@ import java.io.PrintStream; * @since 2.3.0 */ public class ExceptionUtils { - public static void dumpStackTrace(final PrintStream out, final int skip, final int depth) { - dumpStackTrace(out, new Exception(""), skip+1, depth); + public static void dumpStack(final PrintStream out) { + dumpStack(out, 0, -1); } - public static void dumpStackTrace(final PrintStream out, final Throwable t, final int skip, final int depth) { - dumpStackTrace(out, t.getStackTrace(), skip, depth); + public static void dumpStack(final PrintStream out, final int skip, final int depth) { + dumpStack(out, new Exception(""), skip+1, depth); } - public static void dumpStackTrace(final PrintStream out, final StackTraceElement[] stack, final int skip, final int depth) { + public static void dumpStack(final PrintStream out, final Throwable t, final int skip, final int depth) { + dumpStack(out, t.getStackTrace(), skip, depth); + } + public static void dumpStack(final PrintStream out, final StackTraceElement[] stack, final int skip, final int depth) { if( null == stack ) { return; } - final int maxDepth = Math.min(depth+skip, stack.length); + final int maxDepth; + if( 0 > depth ) { + maxDepth = stack.length; + } else { + maxDepth = Math.min(depth+skip, stack.length); + } for(int i=skip; i<maxDepth; i++) { out.println(" ["+i+"]: "+stack[i]); } } /** - * Dumps a Throwable in a decorating message including the current thread name, and stack trace. + * Dumps a {@link Throwable} in a decorating message including the current thread name, + * and its {@link #dumpStack(PrintStream, StackTraceElement[], int, int) stack trace}. */ public static void dumpThrowable(final String additionalDescr, final Throwable t) { System.err.println("Caught "+additionalDescr+" "+t.getClass().getSimpleName()+": "+t.getMessage()+" on thread "+Thread.currentThread().getName()); - t.printStackTrace(); + dumpStack(System.err, t.getStackTrace(), 0, -1); } } diff --git a/src/java/com/jogamp/common/os/NativeLibrary.java b/src/java/com/jogamp/common/os/NativeLibrary.java index e54f5e6..c70bdbd 100644 --- a/src/java/com/jogamp/common/os/NativeLibrary.java +++ b/src/java/com/jogamp/common/os/NativeLibrary.java @@ -56,6 +56,7 @@ import jogamp.common.os.PlatformPropsImpl; import jogamp.common.os.PosixDynamicLinkerImpl; import jogamp.common.os.WindowsDynamicLinkerImpl; +import com.jogamp.common.ExceptionUtils; import com.jogamp.common.util.IOUtil; import com.jogamp.common.util.cache.TempJarCache; @@ -284,7 +285,7 @@ public final class NativeLibrary implements DynamicLookupHelper { dynLink.closeLibrary(handle); if (DEBUG) { System.err.println("NativeLibrary.close(): Successfully closed " + this); - Thread.dumpStack(); + ExceptionUtils.dumpStack(System.err); } } diff --git a/src/java/com/jogamp/common/util/ReflectionUtil.java b/src/java/com/jogamp/common/util/ReflectionUtil.java index 9e716b8..7e8ae63 100644 --- a/src/java/com/jogamp/common/util/ReflectionUtil.java +++ b/src/java/com/jogamp/common/util/ReflectionUtil.java @@ -48,6 +48,7 @@ import java.util.Set; import jogamp.common.Debug; +import com.jogamp.common.ExceptionUtils; import com.jogamp.common.JogampRuntimeException; public final class ReflectionUtil { @@ -140,7 +141,7 @@ public final class ReflectionUtil { System.err.printf("ReflectionUtil.getClassImpl.%03d: %8.3f ms, init %b, [%s]@ Thread %s%n", forNameCount, nanoCosts/1e6, initializeClazz, cnl.toString(), Thread.currentThread().getName()); if(DEBUG) { - Thread.dumpStack(); + ExceptionUtils.dumpStack(System.err); } } return res; |