Package org.codehaus.groovy.classgen.asm
Class MethodCaller
java.lang.Object
org.codehaus.groovy.classgen.asm.MethodCaller
A helper class to invoke methods more easily in ASM
-
Constructor Summary
ConstructorsModifierConstructorDescriptionprotectedMethodCaller(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. -
Method Summary
Modifier and TypeMethodDescriptionvoidcall(org.objectweb.asm.MethodVisitor methodVisitor) Generates the method invocation bytecode.protected MethodReturns the reflectedMethodfor this caller, matching by name and, if specified, by parameter count.Returns the method descriptor for this method call.static MethodCallernewInterface(Class theClass, String name) Creates a MethodCaller for an interface method.static MethodCallerCreates a MethodCaller for a static method.static MethodCallerCreates a MethodCaller for a static method with a specific parameter count.static MethodCallernewVirtual(Class theClass, String name) Creates a MethodCaller for a virtual method.
-
Constructor Details
-
MethodCaller
protected MethodCaller()- Since:
- 2.5.0
-
MethodCaller
Creates a MethodCaller for a specific method invocation.- Parameters:
opcode- the invocation opcodetheClass- the class containing the methodname- the method name
-
MethodCaller
Creates a MethodCaller for a specific method invocation with parameter count.- Parameters:
opcode- the invocation opcodetheClass- the class containing the methodname- the method nameparameterCount- the number of parameters
-
-
Method Details
-
newStatic
Creates a MethodCaller for a static method.- Parameters:
theClass- the class containing the methodname- the method name- Returns:
- a new MethodCaller for a static method
-
newStatic
Creates a MethodCaller for a static method with a specific parameter count.- Parameters:
theClass- the class containing the methodname- the method nameparameterCount- the number of parameters- Returns:
- a new MethodCaller for a static method
-
newInterface
Creates a MethodCaller for an interface method.- Parameters:
theClass- the interface containing the methodname- the method name- Returns:
- a new MethodCaller for an interface method
-
newVirtual
Creates a MethodCaller for a virtual method.- Parameters:
theClass- the class containing the methodname- 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
Returns the method descriptor for this method call.- Returns:
- the method descriptor
-
getMethod
Returns the reflectedMethodfor this caller, matching by name and, if specified, by parameter count.- Returns:
- the matching
Method - Throws:
RuntimeException- if no matching method can be found
-