Class MethodCallHook
- java.lang.Object
-
- com.tonic.analysis.instrumentation.hook.MethodCallHook
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description static classMethodCallHook.BuilderBuilder forMethodCallHook, defaulting to enabled, priority 100, before-call placement, an unrestricted target and no values passed.
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description static MethodCallHookafterCall(String targetClass, String targetMethod, String hookOwner, String hookName, String hookDescriptor)Creates a hook that runs after calls to a named method.static MethodCallHookbeforeCall(String targetClass, String targetMethod, String hookOwner, String hookName, String hookDescriptor)Creates a hook that runs before calls to a named method.static MethodCallHook.Builderbuilder()List<InstrumentationFilter>getFilters()HookDescriptorgetHookDescriptor()intgetPriority()Gets the priority for ordering multiple hooks at the same point.InstrumentationTargetgetTarget()StringgetTargetClass()StringgetTargetDescriptor()StringgetTargetMethod()booleanisAfter()booleanisBefore()booleanisEnabled()booleanisPassArguments()booleanisPassMethodName()booleanisPassReceiver()booleanisPassResult()
-
-
-
Method Detail
-
getHookDescriptor
public HookDescriptor getHookDescriptor()
- Specified by:
getHookDescriptorin interfaceHook- Returns:
- the hook descriptor
-
getFilters
public List<InstrumentationFilter> getFilters()
- Specified by:
getFiltersin interfaceHook- Returns:
- the filters
-
isEnabled
public boolean isEnabled()
-
getPriority
public int getPriority()
Description copied from interface:HookGets the priority for ordering multiple hooks at the same point.- Specified by:
getPriorityin interfaceHook- Returns:
- the priority
-
getTargetClass
public String getTargetClass()
- Returns:
- the target class being called (internal name), or null for any class
-
getTargetMethod
public String getTargetMethod()
- Returns:
- the target method being called, or null for any method on the target class
-
getTargetDescriptor
public String getTargetDescriptor()
- Returns:
- the target method descriptor, or null for any descriptor
-
isBefore
public boolean isBefore()
- Returns:
- whether the hook runs before the call
-
isAfter
public boolean isAfter()
- Returns:
- whether the hook runs after the call
-
isPassReceiver
public boolean isPassReceiver()
- Returns:
- whether the receiver object is passed to the hook
-
isPassArguments
public boolean isPassArguments()
- Returns:
- whether all call arguments are passed to the hook as an
Object[]
-
isPassResult
public boolean isPassResult()
- Returns:
- whether the call result is passed to the hook (after-hooks only)
-
isPassMethodName
public boolean isPassMethodName()
- Returns:
- whether the target method name is passed to the hook
-
getTarget
public InstrumentationTarget getTarget()
-
beforeCall
public static MethodCallHook beforeCall(String targetClass, String targetMethod, String hookOwner, String hookName, String hookDescriptor)
Creates a hook that runs before calls to a named method.- Parameters:
targetClass- internal name of the class whose calls are interceptedtargetMethod- the intercepted method namehookOwner- internal name of the class declaring the hook methodhookName- the hook method namehookDescriptor- the hook method descriptor- Returns:
- the configured hook
-
afterCall
public static MethodCallHook afterCall(String targetClass, String targetMethod, String hookOwner, String hookName, String hookDescriptor)
Creates a hook that runs after calls to a named method.- Parameters:
targetClass- internal name of the class whose calls are interceptedtargetMethod- the intercepted method namehookOwner- internal name of the class declaring the hook methodhookName- the hook method namehookDescriptor- the hook method descriptor- Returns:
- the configured hook
-
builder
public static MethodCallHook.Builder builder()
- Returns:
- a new builder
-
-