Class StackTraceFilter
java.lang.Object
org.mockito.internal.exceptions.stacktrace.StackTraceFilter
- All Implemented Interfaces:
Serializable
- See Also:
-
Field Summary
FieldsModifier and TypeFieldDescriptionprivate static final StackTraceCleaner
private static Method
private static Object
(package private) static final long
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionfilter
(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.filterFirst
(Throwable target, boolean isInline) This filtering strategy makes use of a fast-path computation to retrieve stackTraceElements from a Stacktrace of a Throwable.findSourceFile
(StackTraceElement[] target, String defaultValue) Finds the source file of the target stack trace.
-
Field Details
-
serialVersionUID
static final long serialVersionUID- See Also:
-
CLEANER
-
JAVA_LANG_ACCESS
-
GET_STACK_TRACE_ELEMENT
-
-
Constructor Details
-
StackTraceFilter
public StackTraceFilter()
-
-
Method Details
-
filter
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
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 ofinvalid reference
sun.misc.SharedSecrets
invalid reference
sun.misc.JavaLangAccess
The
invalid reference
sun.misc.SharedSecrets
invalid reference
sun.misc.JavaLangAccess
Throwable.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.- Parameters:
target
- The throwable target to find the firstStackTraceElement
that should not be filtered out perCLEANER
.- Returns:
- The first
StackTraceElement
outside of theCLEANER
-
findSourceFile
Finds the source file of the target stack trace. Returns the default value if source file cannot be found.
-