Class MethodCallProxy

java.lang.Object
net.bytebuddy.implementation.auxiliary.MethodCallProxy
All Implemented Interfaces:
AuxiliaryType

@Enhance public class MethodCallProxy extends Object implements AuxiliaryType
A method call proxy represents a class that is compiled against a particular method which can then be called whenever either its Callable.call() or Runnable.run() method is called where the method call proxy implements both interfaces.

 

In order to do so, the method call proxy instances are constructed by providing all the necessary information for calling a particular method:
  1. If the target method is not static, the first argument should be an instance on which the method is called.
  2. All arguments for the called method in the order in which they are required.
  • Constructor Details

    • MethodCallProxy

      public MethodCallProxy(Implementation.SpecialMethodInvocation specialMethodInvocation, boolean serializableProxy)
      Creates a new method call proxy for a given method and uses a default assigner for assigning the method's return value to either the Callable.call() or Runnable.run() method returns.
      Parameters:
      specialMethodInvocation - The special method invocation which should be invoked by this method call proxy.
      serializableProxy - Determines if the generated proxy should be serializableProxy.
    • MethodCallProxy

      public MethodCallProxy(Implementation.SpecialMethodInvocation specialMethodInvocation, boolean serializableProxy, Assigner assigner)
      Creates a new method call proxy for a given method.
      Parameters:
      specialMethodInvocation - The special method invocation which should be invoked by this method call proxy.
      serializableProxy - Determines if the generated proxy should be serializableProxy.
      assigner - An assigner for assigning the target method's return value to either the Callable.call() or Runnable.run()} methods' return values.
  • Method Details

    • getSuffix

      public String getSuffix()
      Produces a suffix that gives this auxiliary type a stable name. A best effort is made that this suffix is unique.
      Specified by:
      getSuffix in interface AuxiliaryType
      Returns:
      The suffix for this auxiliary type.
    • make

      public DynamicType make(String auxiliaryTypeName, ClassFileVersion classFileVersion, MethodAccessorFactory methodAccessorFactory)
      Creates a new auxiliary type.
      Specified by:
      make in interface AuxiliaryType
      Parameters:
      auxiliaryTypeName - The fully qualified binary name for this auxiliary type. The type should be in the same package than the instrumented type this auxiliary type is providing services to in order to allow package-private access.
      classFileVersion - The class file version the auxiliary class should be written in.
      methodAccessorFactory - A factory for accessor methods.
      Returns:
      A dynamically created type representing this auxiliary type.