Class MockMethodAdvice
- java.lang.Object
-
- org.mockito.internal.creation.bytebuddy.inject.MockMethodDispatcher
-
- org.mockito.internal.creation.bytebuddy.MockMethodAdvice
-
public class MockMethodAdvice extends MockMethodDispatcher
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description (package private) static classMockMethodAdvice.ConstructorShortcut(package private) static classMockMethodAdvice.ForEquals(package private) static classMockMethodAdvice.ForHashCodestatic classMockMethodAdvice.ForReadObject(package private) static classMockMethodAdvice.ForStatic(package private) static interfaceMockMethodAdvice.Identifierprivate static classMockMethodAdvice.RealMethodCallprivate static classMockMethodAdvice.ReturnValueWrapperprivate static classMockMethodAdvice.SelfCallInfoprivate static classMockMethodAdvice.SerializableRealMethodCallprivate static classMockMethodAdvice.StaticMethodCall
-
Field Summary
Fields Modifier and Type Field Description private net.bytebuddy.dynamic.scaffold.MethodGraph.Compilercompilerprivate WeakConcurrentMap<java.lang.Class<?>,java.lang.ref.SoftReference<net.bytebuddy.dynamic.scaffold.MethodGraph>>graphsprivate java.lang.Stringidentifierprivate WeakConcurrentMap<java.lang.Object,MockMethodInterceptor>interceptorsprivate java.util.function.Predicate<java.lang.Class<?>>isMockConstructionprivate DetachedThreadLocal<java.util.Map<java.lang.Class<?>,MockMethodInterceptor>>mockedStaticsprivate ConstructionCallbackonConstructionprivate MockMethodAdvice.SelfCallInfoselfCallInfo
-
Constructor Summary
Constructors Constructor Description MockMethodAdvice(WeakConcurrentMap<java.lang.Object,MockMethodInterceptor> interceptors, DetachedThreadLocal<java.util.Map<java.lang.Class<?>,MockMethodInterceptor>> mockedStatics, java.lang.String identifier, java.util.function.Predicate<java.lang.Class<?>> isMockConstruction, ConstructionCallback onConstruction)
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description private static java.util.concurrent.Callable<?>enter(java.lang.String identifier, java.lang.Object mock, java.lang.reflect.Method origin, java.lang.Object[] arguments)private static voidexit(java.lang.Object returned, java.util.concurrent.Callable<?> mocked)java.util.concurrent.Callable<?>handle(java.lang.Object instance, java.lang.reflect.Method origin, java.lang.Object[] arguments)java.lang.ObjecthandleConstruction(java.lang.Class<?> type, java.lang.Object object, java.lang.Object[] arguments, java.lang.String[] parameterTypeNames)java.util.concurrent.Callable<?>handleStatic(java.lang.Class<?> type, java.lang.reflect.Method origin, java.lang.Object[] arguments)(package private) static java.lang.ThrowablehideRecursiveCall(java.lang.Throwable throwable, int current, java.lang.Class<?> targetType)booleanisConstructorMock(java.lang.Class<?> type)booleanisMock(java.lang.Object instance)booleanisMocked(java.lang.Object instance)booleanisMockedStatic(java.lang.Class<?> type)booleanisOverridden(java.lang.Object instance, java.lang.reflect.Method origin)private static java.lang.ObjecttryInvoke(java.lang.reflect.Method origin, java.lang.Object instance, java.lang.Object[] arguments)-
Methods inherited from class org.mockito.internal.creation.bytebuddy.inject.MockMethodDispatcher
get, getStatic, handleConstruction, isConstructorMock, set
-
-
-
-
Field Detail
-
interceptors
private final WeakConcurrentMap<java.lang.Object,MockMethodInterceptor> interceptors
-
mockedStatics
private final DetachedThreadLocal<java.util.Map<java.lang.Class<?>,MockMethodInterceptor>> mockedStatics
-
identifier
private final java.lang.String identifier
-
selfCallInfo
private final MockMethodAdvice.SelfCallInfo selfCallInfo
-
compiler
private final net.bytebuddy.dynamic.scaffold.MethodGraph.Compiler compiler
-
graphs
private final WeakConcurrentMap<java.lang.Class<?>,java.lang.ref.SoftReference<net.bytebuddy.dynamic.scaffold.MethodGraph>> graphs
-
isMockConstruction
private final java.util.function.Predicate<java.lang.Class<?>> isMockConstruction
-
onConstruction
private final ConstructionCallback onConstruction
-
-
Constructor Detail
-
MockMethodAdvice
public MockMethodAdvice(WeakConcurrentMap<java.lang.Object,MockMethodInterceptor> interceptors, DetachedThreadLocal<java.util.Map<java.lang.Class<?>,MockMethodInterceptor>> mockedStatics, java.lang.String identifier, java.util.function.Predicate<java.lang.Class<?>> isMockConstruction, ConstructionCallback onConstruction)
-
-
Method Detail
-
enter
@OnMethodEnter(skipOn=net.bytebuddy.asm.Advice.OnNonDefaultValue.class) private static java.util.concurrent.Callable<?> enter(java.lang.String identifier, @This java.lang.Object mock, @Origin java.lang.reflect.Method origin, @AllArguments java.lang.Object[] arguments) throws java.lang.Throwable- Throws:
java.lang.Throwable
-
exit
@OnMethodExit private static void exit(@Return(readOnly=false,typing=DYNAMIC) java.lang.Object returned, @Enter java.util.concurrent.Callable<?> mocked) throws java.lang.Throwable- Throws:
java.lang.Throwable
-
hideRecursiveCall
static java.lang.Throwable hideRecursiveCall(java.lang.Throwable throwable, int current, java.lang.Class<?> targetType)
-
handle
public java.util.concurrent.Callable<?> handle(java.lang.Object instance, java.lang.reflect.Method origin, java.lang.Object[] arguments) throws java.lang.Throwable- Specified by:
handlein classMockMethodDispatcher- Throws:
java.lang.Throwable
-
handleStatic
public java.util.concurrent.Callable<?> handleStatic(java.lang.Class<?> type, java.lang.reflect.Method origin, java.lang.Object[] arguments) throws java.lang.Throwable- Specified by:
handleStaticin classMockMethodDispatcher- Throws:
java.lang.Throwable
-
handleConstruction
public java.lang.Object handleConstruction(java.lang.Class<?> type, java.lang.Object object, java.lang.Object[] arguments, java.lang.String[] parameterTypeNames)- Specified by:
handleConstructionin classMockMethodDispatcher
-
isMock
public boolean isMock(java.lang.Object instance)
- Specified by:
isMockin classMockMethodDispatcher
-
isMocked
public boolean isMocked(java.lang.Object instance)
- Specified by:
isMockedin classMockMethodDispatcher
-
isMockedStatic
public boolean isMockedStatic(java.lang.Class<?> type)
- Specified by:
isMockedStaticin classMockMethodDispatcher
-
isOverridden
public boolean isOverridden(java.lang.Object instance, java.lang.reflect.Method origin)- Specified by:
isOverriddenin classMockMethodDispatcher
-
isConstructorMock
public boolean isConstructorMock(java.lang.Class<?> type)
- Specified by:
isConstructorMockin classMockMethodDispatcher
-
tryInvoke
private static java.lang.Object tryInvoke(java.lang.reflect.Method origin, java.lang.Object instance, java.lang.Object[] arguments) throws java.lang.Throwable- Throws:
java.lang.Throwable
-
-