Package net.bytebuddy.asm
Class Advice.Delegator.ForDynamicInvocation
java.lang.Object
net.bytebuddy.asm.Advice.Delegator.ForDynamicInvocation
- All Implemented Interfaces:
Advice.Delegator
- Enclosing interface:
Advice.Delegator
@Enhance
public static class Advice.Delegator.ForDynamicInvocation
extends Object
implements Advice.Delegator
Invokes an advice method using a dynamic method call.
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionprotected static class
A factory for creating a dynamic invocation dispatcher.Nested classes/interfaces inherited from interface net.bytebuddy.asm.Advice.Delegator
Advice.Delegator.ForDynamicInvocation, Advice.Delegator.ForRegularInvocation
-
Field Summary
FieldsModifier and TypeFieldDescriptionprivate final MethodDescription.InDefinedShape
The bootstrap method.private final Advice.BootstrapArgumentResolver
A resolver to provide the arguments to the bootstrap method.private final MethodDescription.SignatureToken
The advice method. -
Constructor Summary
ConstructorsModifierConstructorDescriptionprotected
ForDynamicInvocation
(MethodDescription.InDefinedShape bootstrapMethod, MethodDescription.SignatureToken signatureToken, Advice.BootstrapArgumentResolver resolver) Creates a delegator for a dynamic method invocation. -
Method Summary
Modifier and TypeMethodDescriptionapply
(TypeDescription instrumentedType, MethodDescription instrumentedMethod) Materializes an invocation.void
assertVisibility
(TypeDescription instrumentedType) Asserts the visibility of the delegation target.Returns the advice method's type token.protected static Advice.Delegator.Factory
of
(MethodDescription.InDefinedShape bootstrapMethod, Advice.BootstrapArgumentResolver.Factory resolverFactory, TypeDescription.Generic.Visitor<? extends TypeDescription.Generic> visitor) Creates a new dynamic invocation delegator.
-
Field Details
-
bootstrapMethod
The bootstrap method. -
signatureToken
The advice method. -
resolver
A resolver to provide the arguments to the bootstrap method.
-
-
Constructor Details
-
ForDynamicInvocation
protected ForDynamicInvocation(MethodDescription.InDefinedShape bootstrapMethod, MethodDescription.SignatureToken signatureToken, Advice.BootstrapArgumentResolver resolver) Creates a delegator for a dynamic method invocation.- Parameters:
bootstrapMethod
- The bootstrap method.signatureToken
- The advice method's signature token.resolver
- A resolver to provide the arguments to the bootstrap method.
-
-
Method Details
-
of
protected static Advice.Delegator.Factory of(MethodDescription.InDefinedShape bootstrapMethod, Advice.BootstrapArgumentResolver.Factory resolverFactory, TypeDescription.Generic.Visitor<? extends TypeDescription.Generic> visitor) Creates a new dynamic invocation delegator.- Parameters:
bootstrapMethod
- The bootstrap method or constructor.resolverFactory
- A resolver factory to provide the arguments to the bootstrap method.visitor
- A visitor to apply to the parameter types prior to resolving theMethodType
that is passed to the bootstrap method. The supplied types might not be available to the instrumented type what might make it necessary to camouflage them to avoid class loading errors. The actual type should then rather be passed in a different format by the suppliedAdvice.BootstrapArgumentResolver
.- Returns:
- An appropriate delegator.
-
apply
public StackManipulation apply(TypeDescription instrumentedType, MethodDescription instrumentedMethod) Materializes an invocation.- Specified by:
apply
in interfaceAdvice.Delegator
- Parameters:
instrumentedType
- The instrumented type.instrumentedMethod
- The instrumented method.- Returns:
- An appropriate stack manipulation which needs to consume all arguments for the advice method and needs to provide a compatible return type.
-
getTypeToken
Returns the advice method's type token.- Specified by:
getTypeToken
in interfaceAdvice.Delegator
- Returns:
- The advice method's type token.
-
assertVisibility
Asserts the visibility of the delegation target.- Specified by:
assertVisibility
in interfaceAdvice.Delegator
- Parameters:
instrumentedType
- The instrumented type.
-