Package revxrsal.asm
Interface MethodCaller
- Functional Interface:
- This is a functional interface and can therefore be used as the assignment target for a lambda expression or method reference.
Represents the entrypoint to method callers. This interface is
implemented by the generated classes to invoke targeted methods.
To generate, use wrap(Method) or wrap(Method, ClassLoader).
Implementation note: Generating method callers using ASM to invoke private methods is not possible. Therefore, if a private method is requested, the method handles API will be used to generate method callers.
-
Method Summary
Modifier and TypeMethodDescriptiondefault @NotNull BoundMethodCallerBinds this method caller to the given instance, and returns aBoundMethodCallerthat does not need an instance to be provided for calls.Invokes the methodstatic MethodCallerCreates aMethodCallerthat wraps the given methodstatic MethodCallerwrap(@NotNull Method method, @NotNull ClassLoader loader) Creates aMethodCallerthat wraps the given method, and defines the generated method caller class on the given classloader
-
Method Details
-
call
Invokes the method- Parameters:
instance- Instance to invoke the method on. Can be null for static methods.arguments- Arguments to invoke the method with- Returns:
- The returned value of the method. Will return null for void methods
-
bindTo
Binds this method caller to the given instance, and returns aBoundMethodCallerthat does not need an instance to be provided for calls.For static methods, instance can be
null.- Parameters:
instance- Instance to bind to. Can be null for static methods.- Returns:
- The bound method caller
-
wrap
Creates aMethodCallerthat wraps the given method- Parameters:
method- Method to wrap- Returns:
- The method caller responsible for invoking the method
-
wrap
Creates aMethodCallerthat wraps the given method, and defines the generated method caller class on the given classloader- Parameters:
method- Method to wraploader- Classloader to define the generated method on.- Returns:
- The method caller responsible for invoking the method
-