Class Instrumenter.MethodCallHookBuilder
- java.lang.Object
-
- com.tonic.analysis.instrumentation.Instrumenter.MethodCallHookBuilder
-
- Enclosing class:
- Instrumenter
public static class Instrumenter.MethodCallHookBuilder extends Object
Fluent builder for a method call hook.
-
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description Instrumenter.MethodCallHookBuilderafter()Places the hook call after the instrumented call, clearing the before placement.Instrumenter.MethodCallHookBuilderbefore()Places the hook call before the instrumented call, clearing the after placement.Instrumenter.MethodCallHookBuildercallStatic(String owner, String name, String descriptor)Sets the static method the hook dispatches to.Instrumenter.MethodCallHookBuilderinClass(String className)Restricts this hook to call sites in a single class.Instrumenter.MethodCallHookBuilderinPackage(String packagePrefix)Restricts this hook to call sites under a package.Instrumenter.MethodCallHookBuilderpriority(int priority)Sets the ordering priority of this hook against others at the same site.Instrumenterregister()Attaches the collected filters and registers the hook.Instrumenter.MethodCallHookBuildertargeting(String targetClass, String targetMethod)Restricts this hook to calls of one method, whatever its descriptor.Instrumenter.MethodCallHookBuildertargeting(String targetClass, String targetMethod, String targetDescriptor)Restricts this hook to calls of one exact method signature.Instrumenter.MethodCallHookBuilderwithArguments()Passes the call arguments as hook arguments.Instrumenter.MethodCallHookBuilderwithMethodName()Passes the called method name as a hook argument.Instrumenter.MethodCallHookBuilderwithReceiver()Passes the call receiver as a hook argument.Instrumenter.MethodCallHookBuilderwithResult()Passes the call result as a hook argument.
-
-
-
Method Detail
-
inClass
public Instrumenter.MethodCallHookBuilder inClass(String className)
Restricts this hook to call sites in a single class.- Parameters:
className- the internal class name- Returns:
- this builder
-
inPackage
public Instrumenter.MethodCallHookBuilder inPackage(String packagePrefix)
Restricts this hook to call sites under a package.- Parameters:
packagePrefix- the internal package name prefix- Returns:
- this builder
-
targeting
public Instrumenter.MethodCallHookBuilder targeting(String targetClass, String targetMethod)
Restricts this hook to calls of one method, whatever its descriptor.- Parameters:
targetClass- internal name of the called classtargetMethod- the called method name- Returns:
- this builder
-
targeting
public Instrumenter.MethodCallHookBuilder targeting(String targetClass, String targetMethod, String targetDescriptor)
Restricts this hook to calls of one exact method signature.- Parameters:
targetClass- internal name of the called classtargetMethod- the called method nametargetDescriptor- the called method descriptor- Returns:
- this builder
-
before
public Instrumenter.MethodCallHookBuilder before()
Places the hook call before the instrumented call, clearing the after placement.- Returns:
- this builder
-
after
public Instrumenter.MethodCallHookBuilder after()
Places the hook call after the instrumented call, clearing the before placement.- Returns:
- this builder
-
callStatic
public Instrumenter.MethodCallHookBuilder callStatic(String owner, String name, String descriptor)
Sets the static method the hook dispatches to.- Parameters:
owner- internal name of the class declaring the hook methodname- the hook method namedescriptor- the hook method descriptor- Returns:
- this builder
-
withReceiver
public Instrumenter.MethodCallHookBuilder withReceiver()
Passes the call receiver as a hook argument.- Returns:
- this builder
-
withArguments
public Instrumenter.MethodCallHookBuilder withArguments()
Passes the call arguments as hook arguments.- Returns:
- this builder
-
withResult
public Instrumenter.MethodCallHookBuilder withResult()
Passes the call result as a hook argument.- Returns:
- this builder
-
withMethodName
public Instrumenter.MethodCallHookBuilder withMethodName()
Passes the called method name as a hook argument.- Returns:
- this builder
-
priority
public Instrumenter.MethodCallHookBuilder priority(int priority)
Sets the ordering priority of this hook against others at the same site.- Parameters:
priority- the priority value- Returns:
- this builder
-
register
public Instrumenter register()
Attaches the collected filters and registers the hook.- Returns:
- the instrumenter this builder came from
-
-