Class TypeProxy
java.lang.Object
net.bytebuddy.implementation.auxiliary.TypeProxy
- All Implemented Interfaces:
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.
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionprotected static enumA stack manipulation that throws an abstract method error in case that a given super method cannot be invoked.static classCreates a type proxy which delegates its super method calls to any invokable default method of a given interface and loads an instance of this proxy onto the operand stack.static classLoads a type proxy onto the operand stack which is created by calling one of its constructors.static classLoads a type proxy onto the operand stack which is created by constructing a serialization constructor using the Oracle JDK'sReflectionFactory.newConstructorForSerialization(Class, java.lang.reflect.Constructor)method which might not be available in any Java runtime.static interfaceAn invocation factory is responsible for creating a special method invocation for any method that is to be invoked.protected classAn implementation for a method call of aTypeProxy.protected static enumAn implementation of a silent construction of a given type by using the non-standardizedReflectionFactory.Nested classes/interfaces inherited from interface AuxiliaryType
AuxiliaryType.NamingStrategy, AuxiliaryType.SignatureRelevant -
Field Summary
FieldsModifier and TypeFieldDescriptionprivate final booleantrueif the finalizer method should not be instrumented.private final Implementation.TargetThe implementation target of the proxied type.static final StringThe name of the field that stores the delegation instance.private final TypeProxy.InvocationFactoryThe invocation factory for creating special method invocations.private final TypeDescriptionThe type that is proxied, i.e.static final StringThe name of thestaticmethod that is added to this auxiliary type for creating instances by using the Oracle JDK'sReflectionFactory.private final booleanDetermines if the proxy should be serializable.Fields inherited from interface AuxiliaryType
DEFAULT_TYPE_MODIFIER -
Constructor Summary
ConstructorsConstructorDescriptionTypeProxy(TypeDescription proxiedType, Implementation.Target implementationTarget, TypeProxy.InvocationFactory invocationFactory, boolean ignoreFinalizer, boolean serializableProxy) Creates a new type proxy. -
Method Summary
Modifier and TypeMethodDescriptionProduces a suffix that gives this auxiliary type a stable name.make(String auxiliaryTypeName, ClassFileVersion classFileVersion, MethodAccessorFactory methodAccessorFactory) Creates a new auxiliary type.
-
Field Details
-
REFLECTION_METHOD
The name of thestaticmethod that is added to this auxiliary type for creating instances by using the Oracle JDK'sReflectionFactory.- See Also:
-
INSTANCE_FIELD
The name of the field that stores the delegation instance.- See Also:
-
proxiedType
The type that is proxied, i.e. the original instrumented type this proxy is created for. -
implementationTarget
The implementation target of the proxied type. -
invocationFactory
The invocation factory for creating special method invocations. -
ignoreFinalizer
private final boolean ignoreFinalizertrueif the finalizer method should not be instrumented. -
serializableProxy
private final boolean serializableProxyDetermines 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-trueif any finalizer methods should be ignored for proxying.serializableProxy- Determines if the proxy should be serializable.
-
-
Method Details
-
getSuffix
Produces a suffix that gives this auxiliary type a stable name. A best effort is made that this suffix is unique.- Specified by:
getSuffixin interfaceAuxiliaryType- Returns:
- The suffix for this auxiliary type.
-
make
public DynamicType make(String auxiliaryTypeName, ClassFileVersion classFileVersion, MethodAccessorFactory methodAccessorFactory) Creates a new auxiliary type.- Specified by:
makein interfaceAuxiliaryType- 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.
-