Class Pipe.Binder.Redirection
- java.lang.Object
-
- net.bytebuddy.implementation.bind.annotation.Pipe.Binder.Redirection
-
- All Implemented Interfaces:
AuxiliaryType
,StackManipulation
- Enclosing class:
- Pipe.Binder
@Enhance protected static class Pipe.Binder.Redirection extends java.lang.Object implements AuxiliaryType, StackManipulation
An auxiliary type for performing the redirection of a method invocation as requested by thePipe
annotation.
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description protected static class
Pipe.Binder.Redirection.ConstructorCall
The implementation to implement aPipe.Binder.Redirection
's constructor.protected static class
Pipe.Binder.Redirection.MethodCall
The implementation to implement aPipe.Binder.Redirection
's forwarding method.-
Nested classes/interfaces inherited from interface net.bytebuddy.implementation.auxiliary.AuxiliaryType
AuxiliaryType.NamingStrategy, AuxiliaryType.SignatureRelevant
-
Nested classes/interfaces inherited from interface net.bytebuddy.implementation.bytecode.StackManipulation
StackManipulation.Compound, StackManipulation.Illegal, StackManipulation.Size, StackManipulation.Trivial
-
-
Field Summary
Fields Modifier and Type Field Description private Assigner
assigner
The assigner to use.private static java.lang.String
FIELD_NAME_PREFIX
The prefix for naming fields to store method arguments.private TypeDescription
forwardingType
The type that declares the method for forwarding a method invocation.private boolean
serializableProxy
Determines if the generated proxy should beSerializable
.private MethodDescription
sourceMethod
The method that is to be forwarded.-
Fields inherited from interface net.bytebuddy.implementation.auxiliary.AuxiliaryType
DEFAULT_TYPE_MODIFIER
-
-
Constructor Summary
Constructors Modifier Constructor Description protected
Redirection(TypeDescription forwardingType, MethodDescription sourceMethod, Assigner assigner, boolean serializableProxy)
Creates a new redirection.
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description StackManipulation.Size
apply(org.objectweb.asm.MethodVisitor methodVisitor, Implementation.Context implementationContext)
Applies the stack manipulation that is described by this instance.private static java.util.LinkedHashMap<java.lang.String,TypeDescription>
extractFields(MethodDescription methodDescription)
Extracts all parameters of a method to fields.private static java.lang.String
fieldName(int index)
Creates a new field name.boolean
isValid()
Determines if this stack manipulation is valid.DynamicType
make(java.lang.String auxiliaryTypeName, ClassFileVersion classFileVersion, MethodAccessorFactory methodAccessorFactory)
Creates a new auxiliary type.
-
-
-
Field Detail
-
FIELD_NAME_PREFIX
private static final java.lang.String FIELD_NAME_PREFIX
The prefix for naming fields to store method arguments.- See Also:
- Constant Field Values
-
forwardingType
private final TypeDescription forwardingType
The type that declares the method for forwarding a method invocation.
-
sourceMethod
private final MethodDescription sourceMethod
The method that is to be forwarded.
-
assigner
private final Assigner assigner
The assigner to use.
-
serializableProxy
private final boolean serializableProxy
Determines if the generated proxy should beSerializable
.
-
-
Constructor Detail
-
Redirection
protected Redirection(TypeDescription forwardingType, MethodDescription sourceMethod, Assigner assigner, boolean serializableProxy)
Creates a new redirection.- Parameters:
forwardingType
- The type that declares the method for forwarding a method invocation.sourceMethod
- The method that is to be forwarded.assigner
- The assigner to use.serializableProxy
- Determines if the generated proxy should beSerializable
.
-
-
Method Detail
-
extractFields
private static java.util.LinkedHashMap<java.lang.String,TypeDescription> extractFields(MethodDescription methodDescription)
Extracts all parameters of a method to fields.- Parameters:
methodDescription
- The method to extract the parameters from.- Returns:
- A linked hash map of field names to the types of these fields representing all parameters of the given method.
-
fieldName
private static java.lang.String fieldName(int index)
Creates a new field name.- Parameters:
index
- The index of the field.- Returns:
- The field name that corresponds to the index.
-
make
public DynamicType make(java.lang.String auxiliaryTypeName, ClassFileVersion classFileVersion, MethodAccessorFactory methodAccessorFactory)
Creates a new auxiliary type.- Specified by:
make
in 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.
-
isValid
public boolean isValid()
Determines if this stack manipulation is valid.- Specified by:
isValid
in interfaceStackManipulation
- Returns:
- If
false
, this manipulation cannot be applied and should throw an exception.
-
apply
public StackManipulation.Size apply(org.objectweb.asm.MethodVisitor methodVisitor, Implementation.Context implementationContext)
Applies the stack manipulation that is described by this instance.- Specified by:
apply
in interfaceStackManipulation
- Parameters:
methodVisitor
- The method visitor used to write the method implementation to.implementationContext
- The context of the current implementation.- Returns:
- The changes to the size of the operand stack that are implied by this stack manipulation.
-
-