Package: org.codehaus.groovy.classgen.asm

## [Java] Class MethodCaller

- org.codehaus.groovy.classgen.asm.MethodCaller

-     public class MethodCaller
      extends Object

  A helper class to invoke methods more easily in ASM

- - ### Constructor Summary

    Constructors
    Constructor and description
    `protected MethodCaller()` Since: 2.5.0
    `MethodCaller(int opcode, Class theClass, String name)` Creates a MethodCaller for a specific method invocation.
    `MethodCaller(int opcode, Class theClass, String name, int parameterCount)` Creates a MethodCaller for a specific method invocation with parameter count.

  - ### Methods Summary

    Methods
    Type Params | Return Type | Name and description
    --- | --- | ---
    `` | `public void` | `call(org.objectweb.asm.MethodVisitor methodVisitor)` Generates the method invocation bytecode.
    `` | `protected Method` | `getMethod()` Returns the reflected Method for this caller, matching by name and, if specified, by parameter count.
    `` | `public String` | `getMethodDescriptor()` Returns the method descriptor for this method call.
    `` | `public static MethodCaller` | `newInterface(Class theClass, String name)` Creates a MethodCaller for an interface method.
    `` | `public static MethodCaller` | `newStatic(Class theClass, String name)` Creates a MethodCaller for a static method.
    `` | `public static MethodCaller` | `newStatic(Class theClass, String name, int parameterCount)` Creates a MethodCaller for a static method with a specific parameter count.
    `` | `public static MethodCaller` | `newVirtual(Class theClass, String name)` Creates a MethodCaller for a virtual method.

  - ### Inherited Methods Summary

    Inherited Methods
    Methods inherited from class | Name
    --- | ---
    `class Object` | `equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

- - ### Constructor Detail

    - #### protected MethodCaller()

      Since:
        2.5.0

    - #### public MethodCaller(int opcode, Class theClass, String name)

      Creates a MethodCaller for a specific method invocation.

      Parameters:
        `opcode` - the invocation opcode
        `theClass` - the class containing the method
        `name` - the method name

    - #### public MethodCaller(int opcode, Class theClass, String name, int parameterCount)

      Creates a MethodCaller for a specific method invocation with parameter count.

      Parameters:
        `opcode` - the invocation opcode
        `theClass` - the class containing the method
        `name` - the method name
        `parameterCount` - the number of parameters

  - ### Method Detail

    - #### public void call(org.objectweb.asm.MethodVisitor methodVisitor)

      Generates the method invocation bytecode.

      Parameters:
        `methodVisitor` - the method visitor to write to

    - #### protected Method getMethod()

      Returns the reflected Method for this caller, matching by name and, if specified, by parameter count.

      throws:
        RuntimeException if no matching method can be found
      Returns:
        the matching Method

    - #### public String getMethodDescriptor()

      Returns the method descriptor for this method call.

      Returns:
        the method descriptor

    - #### public static MethodCaller newInterface(Class theClass, String name)

      Creates a MethodCaller for an interface method.

      Parameters:
        `theClass` - the interface containing the method
        `name` - the method name
      Returns:
        a new MethodCaller for an interface method

    - #### public static MethodCaller newStatic(Class theClass, String name)

      Creates a MethodCaller for a static method.

      Parameters:
        `theClass` - the class containing the method
        `name` - the method name
      Returns:
        a new MethodCaller for a static method

    - #### public static MethodCaller newStatic(Class theClass, String name, int parameterCount)

      Creates a MethodCaller for a static method with a specific parameter count.

      Parameters:
        `theClass` - the class containing the method
        `name` - the method name
        `parameterCount` - the number of parameters
      Returns:
        a new MethodCaller for a static method

    - #### public static MethodCaller newVirtual(Class theClass, String name)

      Creates a MethodCaller for a virtual method.

      Parameters:
        `theClass` - the class containing the method
        `name` - the method name
      Returns:
        a new MethodCaller for a virtual method