Class MethodCaller

java.lang.Object
org.codehaus.groovy.classgen.asm.MethodCaller

public class MethodCaller extends Object
A helper class to invoke methods more easily in ASM
  • Constructor Details

    • MethodCaller

      protected MethodCaller()
      Since:
      2.5.0
    • MethodCaller

      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
    • MethodCaller

      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 Details

    • newStatic

      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
    • newStatic

      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
    • newInterface

      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
    • newVirtual

      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
    • call

      public void call(org.objectweb.asm.MethodVisitor methodVisitor)
      Generates the method invocation bytecode.
      Parameters:
      methodVisitor - the method visitor to write to
    • getMethodDescriptor

      public String getMethodDescriptor()
      Returns the method descriptor for this method call.
      Returns:
      the method descriptor
    • getMethod

      protected Method getMethod()
      Returns the reflected Method for this caller, matching by name and, if specified, by parameter count.
      Returns:
      the matching Method
      Throws:
      RuntimeException - if no matching method can be found