Class StackTraceFilter
- java.lang.Object
-
- org.mockito.internal.exceptions.stacktrace.StackTraceFilter
-
- All Implemented Interfaces:
java.io.Serializable
public class StackTraceFilter extends java.lang.Object implements java.io.Serializable
- See Also:
- Serialized Form
-
-
Field Summary
Fields Modifier and Type Field Description private static StackTraceCleaner
CLEANER
private static java.lang.reflect.Method
GET_STACK_TRACE_ELEMENT
private static java.lang.Object
JAVA_LANG_ACCESS
(package private) static long
serialVersionUID
-
Constructor Summary
Constructors Constructor Description StackTraceFilter()
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description java.lang.StackTraceElement[]
filter(java.lang.StackTraceElement[] target, boolean keepTop)
Example how the filter works (+/- means good/bad): [a+, b+, c-, d+, e+, f-, g+] -> [a+, b+, d+, e+, g+] Basically removes all bad from the middle.java.lang.StackTraceElement
filterFirst(java.lang.Throwable target, boolean isInline)
This filtering strategy makes use of a fast-path computation to retrieve stackTraceElements from a Stacktrace of a Throwable.java.lang.String
findSourceFile(java.lang.StackTraceElement[] target, java.lang.String defaultValue)
Finds the source file of the target stack trace.
-
-
-
Field Detail
-
serialVersionUID
static final long serialVersionUID
- See Also:
- Constant Field Values
-
CLEANER
private static final StackTraceCleaner CLEANER
-
JAVA_LANG_ACCESS
private static java.lang.Object JAVA_LANG_ACCESS
-
GET_STACK_TRACE_ELEMENT
private static java.lang.reflect.Method GET_STACK_TRACE_ELEMENT
-
-
Method Detail
-
filter
public java.lang.StackTraceElement[] filter(java.lang.StackTraceElement[] target, boolean keepTop)
Example how the filter works (+/- means good/bad): [a+, b+, c-, d+, e+, f-, g+] -> [a+, b+, d+, e+, g+] Basically removes all bad from the middle.If any good are in the middle of bad those are also removed.
-
filterFirst
public java.lang.StackTraceElement filterFirst(java.lang.Throwable target, boolean isInline)
This filtering strategy makes use of a fast-path computation to retrieve stackTraceElements from a Stacktrace of a Throwable. It does so, by taking advantage ofsun.misc.SharedSecrets
andsun.misc.JavaLangAccess
.The
sun.misc.SharedSecrets
provides a method to obtain an instance of ansun.misc.JavaLangAccess
. The latter class has a method to fast-path intoThrowable.getStackTrace()
and retrieve a singleStackTraceElement
. This prevents the JVM from having to generate a full stacktrace, which could potentially be expensive if stacktraces become very large.
-
findSourceFile
public java.lang.String findSourceFile(java.lang.StackTraceElement[] target, java.lang.String defaultValue)
Finds the source file of the target stack trace. Returns the default value if source file cannot be found.
-
-