Class StackTraceFilter
java.lang.Object
org.mockito.internal.exceptions.stacktrace.StackTraceFilter
- All Implemented Interfaces:
Serializable
- See Also:
-
Field Summary
FieldsModifier and TypeFieldDescriptionprivate static final StackTraceCleanerprivate static Methodprivate 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 ofandinvalid reference
sun.misc.SharedSecrets.invalid reference
sun.misc.JavaLangAccessThe
provides a method to obtain an instance of aninvalid reference
sun.misc.SharedSecrets. The latter class has a method to fast-path intoinvalid reference
sun.misc.JavaLangAccessThrowable.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 firstStackTraceElementthat should not be filtered out perCLEANER.- Returns:
- The first
StackTraceElementoutside of theCLEANER
-
findSourceFile
Finds the source file of the target stack trace. Returns the default value if source file cannot be found.
-