Package org.mockito.internal.debugging
Class LocationImpl
java.lang.Object
org.mockito.internal.debugging.LocationImpl
- All Implemented Interfaces:
Serializable
,Location
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionprivate static final class
private static final class
-
Field Summary
FieldsModifier and TypeFieldDescriptionprivate static final int
This is an unfortunate buffer.private static final StackTraceCleaner
private static final Predicate
<StackTraceCleaner.StackFrameMetadata> private static final int
private static final String
private static final long
private final StackTraceCleaner.StackFrameMetadata
private String
private static final Function
<StackTraceElement, StackTraceCleaner.StackFrameMetadata> In Java, allocating lambdas is cheap, but not free.private static final String
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionprivate static int
In order to trigger the stack walker, we create some reflective frames.Source file of this locationprivate static StackTraceCleaner.StackFrameMetadata
getStackFrame
(boolean isInline) private static String
private String
toString()
Human readable location in the source code, seeInvocation.getLocation()
private static boolean
-
Field Details
-
serialVersionUID
private static final long serialVersionUID- See Also:
-
UNEXPECTED_ERROR_SUFFIX
- See Also:
-
BUFFER_SIZE
private static final int BUFFER_SIZEThis is an unfortunate buffer. Inside StackWalker, a buffer is created, which is resized by doubling. The resizing also allocates a tonne of StackFrame elements. If we traverse more than BUFFER_SIZE elements, the resulting resize can significantly affect the overall cost of the operation. If we traverse fewer than this number, we are inefficient. Empirically, 16 is enough stack frames for a simple stub+call operation to succeed without resizing, as measured on Java 11.- See Also:
-
PREFIX
- See Also:
-
CLEANER
-
toStackFrameMetadata
private static final Function<StackTraceElement,StackTraceCleaner.StackFrameMetadata> toStackFrameMetadataIn Java, allocating lambdas is cheap, but not free. stream.map(this::doSomething) will allocate a Function object each time the function is called (although not per element). By assigning these Functions and Predicates to variables, we can avoid the memory allocation. -
cleanerIsIn
-
FRAMES_TO_SKIP
private static final int FRAMES_TO_SKIP -
sfm
-
stackTraceLine
-
-
Constructor Details
-
LocationImpl
LocationImpl(boolean isInline)
-
-
Method Details
-
getSourceFile
Description copied from interface:Location
Source file of this location- Specified by:
getSourceFile
in interfaceLocation
- Returns:
- source file
-
toString
Description copied from interface:Location
Human readable location in the source code, seeInvocation.getLocation()
-
stackTraceLine
-
getStackFrame
-
usingDefaultStackTraceCleaner
private static boolean usingDefaultStackTraceCleaner() -
noStackTraceFailureMessage
-
framesToSkip
private static int framesToSkip()In order to trigger the stack walker, we create some reflective frames. These need to be skipped so as to ensure there are no non-Mockito frames at the top of the stack trace.
-