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 java.lang.Object implements Advice.Delegator
Invokes an advice method using a dynamic method call.
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description protected static classAdvice.Delegator.ForDynamicInvocation.FactoryA 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
Fields Modifier and Type Field Description private MethodDescription.InDefinedShapebootstrapMethodThe bootstrap method.private Advice.BootstrapArgumentResolverresolverA resolver to provide the arguments to the bootstrap method.private MethodDescription.SignatureTokensignatureTokenThe advice method.
-
Constructor Summary
Constructors Modifier Constructor Description protectedForDynamicInvocation(MethodDescription.InDefinedShape bootstrapMethod, MethodDescription.SignatureToken signatureToken, Advice.BootstrapArgumentResolver resolver)Creates a delegator for a dynamic method invocation.
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description StackManipulationapply(TypeDescription instrumentedType, MethodDescription instrumentedMethod)Materializes an invocation.voidassertVisibility(TypeDescription instrumentedType)Asserts the visibility of the delegation target.MethodDescription.TypeTokengetTypeToken()Returns the advice method's type token.protected static Advice.Delegator.Factoryof(MethodDescription.InDefinedShape bootstrapMethod, Advice.BootstrapArgumentResolver.Factory resolverFactory, TypeDescription.Generic.Visitor<? extends TypeDescription.Generic> visitor)Creates a new dynamic invocation delegator.
-
-
-
Field Detail
-
bootstrapMethod
private final MethodDescription.InDefinedShape bootstrapMethod
The bootstrap method.
-
signatureToken
private final MethodDescription.SignatureToken signatureToken
The advice method.
-
resolver
private final Advice.BootstrapArgumentResolver resolver
A resolver to provide the arguments to the bootstrap method.
-
-
Constructor Detail
-
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 Detail
-
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 theMethodTypethat 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:
applyin 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
public MethodDescription.TypeToken getTypeToken()
Returns the advice method's type token.- Specified by:
getTypeTokenin interfaceAdvice.Delegator- Returns:
- The advice method's type token.
-
assertVisibility
public void assertVisibility(TypeDescription instrumentedType)
Asserts the visibility of the delegation target.- Specified by:
assertVisibilityin interfaceAdvice.Delegator- Parameters:
instrumentedType- The instrumented type.
-
-