Class TypeProxy

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

@Enhance public class TypeProxy extends Object implements AuxiliaryType
A type proxy creates accessor methods for all overridable methods of a given type by subclassing the given type and delegating all method calls to accessor methods of the instrumented type it was created for.
  • Field Details

    • REFLECTION_METHOD

      public static final String REFLECTION_METHOD
      The name of the static method that is added to this auxiliary type for creating instances by using the Oracle JDK's ReflectionFactory.
      See Also:
    • INSTANCE_FIELD

      public static final String INSTANCE_FIELD
      The name of the field that stores the delegation instance.
      See Also:
    • proxiedType

      private final TypeDescription proxiedType
      The type that is proxied, i.e. the original instrumented type this proxy is created for.
    • implementationTarget

      private final Implementation.Target implementationTarget
      The implementation target of the proxied type.
    • invocationFactory

      private final TypeProxy.InvocationFactory invocationFactory
      The invocation factory for creating special method invocations.
    • ignoreFinalizer

      private final boolean ignoreFinalizer
      true if the finalizer method should not be instrumented.
    • serializableProxy

      private final boolean serializableProxy
      Determines if the proxy should be serializable.
  • Constructor Details

    • TypeProxy

      public TypeProxy(TypeDescription proxiedType, Implementation.Target implementationTarget, TypeProxy.InvocationFactory invocationFactory, boolean ignoreFinalizer, boolean serializableProxy)
      Creates a new type proxy.
      Parameters:
      proxiedType - The type this proxy should implement which can either be a non-final class or an interface.
      implementationTarget - The implementation target this type proxy is created for.
      invocationFactory - The invocation factory for creating special method invocations.
      ignoreFinalizer - true if any finalizer methods should be ignored for proxying.
      serializableProxy - Determines if the proxy should be serializable.
  • 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.