Class MethodCallHook

  • All Implemented Interfaces:
    Hook

    public class MethodCallHook
    extends Object
    implements Hook
    Configuration for method call interception.
    • Method Detail

      • isEnabled

        public boolean isEnabled()
        Specified by:
        isEnabled in interface Hook
        Returns:
        whether enabled
      • getPriority

        public int getPriority()
        Description copied from interface: Hook
        Gets the priority for ordering multiple hooks at the same point.
        Specified by:
        getPriority in interface Hook
        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
      • 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 intercepted
        targetMethod - the intercepted method name
        hookOwner - internal name of the class declaring the hook method
        hookName - the hook method name
        hookDescriptor - 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 intercepted
        targetMethod - the intercepted method name
        hookOwner - internal name of the class declaring the hook method
        hookName - the hook method name
        hookDescriptor - the hook method descriptor
        Returns:
        the configured hook