This library allows you to capture stack traces with more information than Throwable.getStackTrace
.
In addition to the information in the JDK's StackTraceElement
The captured stack elements contain:
- The decalaring class -- the actual
Class
object -- not just the name. - The method -- the actual
Method
object -- not just the method name. - The bytecode index
Works best when running on a Java 8 HotSpot (OpenJDK/Oracle JDK) JVM.
Advanced Beta. Used in Quasar.
-
Clone and build the repository with
./gradlew
or use Maven artifactco.paralleluniverse:extended-stacktrace:0.1.0-SNAPSHOT
from the Sonatype snapshot repository (https://oss.sonatype.org/content/repositories/snapshots
) -
Add the JAR file to your dependencies.
-
Obtain the extended stack trace information with
ExtendedStackTrace.here()
orExtendedStackTrace.of(Throwable)
Please consult the Javadocs for detailed information.
On the HotSpot JVM (OpenJDK/Oracle JDK) for Java 8, the extended information is always available (via some deep hacking), and obtaining it is as efficient as a plain Throwable.getStackTrace()
.
On other JVMs/Java versions the extended information may be incomplete. There are (much) better chances for obtaining extended information when capturing the stack with
ExtendedStackTrace.here()
than when extracting extended information from a Throwable
with ExtendedStackTrace.of(Throwable)
. Also, getting the method object carries a significant cost.
This project is free software free software published under the following license:
Copyright (c) 2015, Parallel Universe Software Co. All rights reserved.
This program and the accompanying materials are licensed under
GNU General Public License, version 2, with the Classpath Exception (same as OpenJDK)
http://openjdk.java.net/legal/gplv2+ce.html