Package net.bytebuddy.asm
Class Advice.WithCustomMapping
java.lang.Object
net.bytebuddy.asm.Advice.WithCustomMapping
- Enclosing class:
Advice
A builder step for creating an
Advice
that uses custom mappings of annotations to constant pool values.-
Field Summary
FieldsModifier and TypeFieldDescriptionprivate final AsmClassReader.Factory
The class reader factory to use.private final Advice.Delegator.Factory
The delegator factory to use.private final Map
<Class<? extends Annotation>, Advice.OffsetMapping.Factory<?>> A map containing dynamically computed constant pool values that are mapped by their triggering annotation type.private final Advice.PostProcessor.Factory
The post processor factory to apply. -
Constructor Summary
ConstructorsModifierConstructorDescriptionprotected
Creates a new custom mapping builder step without including any custom mappings.protected
WithCustomMapping
(Advice.PostProcessor.Factory postProcessorFactory, Map<Class<? extends Annotation>, Advice.OffsetMapping.Factory<?>> offsetMappings, Advice.Delegator.Factory delegatorFactory, AsmClassReader.Factory classReaderFactory) Creates a new custom mapping builder step with the given custom mappings. -
Method Summary
Modifier and TypeMethodDescription<T extends Annotation>
Advice.WithCustomMappingBinds the supplied annotation to the supplied type constant.<T extends Annotation>
Advice.WithCustomMappingBinds the supplied annotation to the supplied enumeration constant.<T extends Annotation>
Advice.WithCustomMappingBinds the supplied annotation to a type constant of the supplied value.<T extends Annotation>
Advice.WithCustomMappingbind
(Class<T> type, Constructor<?> constructor, int index) Binds the supplied annotation to the supplied parameter's argument.<T extends Annotation>
Advice.WithCustomMappingBinds the supplied annotation to the value of the supplied field.<T extends Annotation>
Advice.WithCustomMappingBinds the supplied annotation to the supplied parameter's argument.<T extends Annotation>
Advice.WithCustomMappingbind
(Class<T> type, Advice.OffsetMapping offsetMapping) Binds the supplied annotation to the annotation's property of the specified name.<T extends Annotation>
Advice.WithCustomMappingbind
(Class<T> type, EnumerationDescription value) Binds the supplied annotation to the supplied enumeration constant.<T extends Annotation>
Advice.WithCustomMappingbind
(Class<T> type, FieldDescription fieldDescription) Binds the supplied annotation to the value of the supplied field.<T extends Annotation>
Advice.WithCustomMappingbind
(Class<T> type, ParameterDescription parameterDescription) Binds the supplied annotation to the supplied parameter's argument.<T extends Annotation>
Advice.WithCustomMappingbind
(Class<T> type, TypeDescription value) Binds the supplied annotation to the supplied type constant.<T extends Annotation>
Advice.WithCustomMappingbind
(Class<T> type, StackManipulation stackManipulation, Type targetType) Binds the supplied annotation to the annotation's property of the specified name.<T extends Annotation>
Advice.WithCustomMappingbind
(Class<T> type, StackManipulation stackManipulation, TypeDescription.Generic targetType) Binds the supplied annotation to the annotation's property of the specified name.<T extends Annotation>
Advice.WithCustomMappingbind
(Class<T> type, ConstantValue constant) Binds the supplied annotation to the given Java constant.<T extends Annotation>
Advice.WithCustomMappingbind
(Class<T> type, JavaConstant constant) Binds the supplied annotation to the given Java constant.bind
(Advice.OffsetMapping.Factory<?> offsetMapping) Binds an annotation to a dynamically computed value.<T extends Annotation>
Advice.WithCustomMappingbindDynamic
(Class<T> type, Constructor<?> bootstrapMethod, Object... constant) Binds the supplied annotation to a dynamically bootstrapped value.<T extends Annotation>
Advice.WithCustomMappingbindDynamic
(Class<T> type, Constructor<?> bootstrapMethod, List<?> constants) Binds the supplied annotation to a dynamically bootstrapped value.<T extends Annotation>
Advice.WithCustomMappingbindDynamic
(Class<T> type, Method bootstrapMethod, Object... constant) Binds the supplied annotation to a dynamically bootstrapped value.<T extends Annotation>
Advice.WithCustomMappingbindDynamic
(Class<T> type, Method bootstrapMethod, List<?> constants) Binds the supplied annotation to a dynamically bootstrapped value.<T extends Annotation>
Advice.WithCustomMappingbindDynamic
(Class<T> type, MethodDescription.InDefinedShape bootstrapMethod, Object... constant) Binds the supplied annotation to a dynamically bootstrapped value.<T extends Annotation>
Advice.WithCustomMappingbindDynamic
(Class<T> type, MethodDescription.InDefinedShape bootstrapMethod, List<?> constants) Binds the supplied annotation to a dynamically bootstrapped value.<T extends Annotation>
Advice.WithCustomMappingbindLambda
(Class<T> type, Constructor<?> constructor, Class<?> functionalInterface) Binds the supplied annotation as a lambda expression via the JVM's lambda metafactory.<T extends Annotation>
Advice.WithCustomMappingbindLambda
(Class<T> type, Constructor<?> constructor, Class<?> functionalInterface, MethodGraph.Compiler methodGraphCompiler) Binds the supplied annotation as a lambda expression via the JVM's lambda metafactory.<T extends Annotation>
Advice.WithCustomMappingbindLambda
(Class<T> type, Method method, Class<?> functionalInterface) Binds the supplied annotation as a lambda expression via the JVM's lambda metafactory.<T extends Annotation>
Advice.WithCustomMappingbindLambda
(Class<T> type, Method method, Class<?> functionalInterface, MethodGraph.Compiler methodGraphCompiler) Binds the supplied annotation as a lambda expression via the JVM's lambda metafactory.<T extends Annotation>
Advice.WithCustomMappingbindLambda
(Class<T> type, MethodDescription.InDefinedShape methodDescription, TypeDescription functionalInterface) Binds the supplied annotation as a lambda expression via the JVM's lambda metafactory.<T extends Annotation>
Advice.WithCustomMappingbindLambda
(Class<T> type, MethodDescription.InDefinedShape methodDescription, TypeDescription functionalInterface, MethodGraph.Compiler methodGraphCompiler) Binds the supplied annotation as a lambda expression via the JVM's lambda metafactory.<T extends Annotation>
Advice.WithCustomMappingbindProperty
(Class<T> type, String property) Binds the supplied annotation to the annotation's property of the specified name.<T extends Annotation>
Advice.WithCustomMappingbindSerialized
(Class<T> type, Serializable value) Binds the supplied annotation to the supplied fixed value.<T extends Annotation,
S extends Serializable>
Advice.WithCustomMappingbindSerialized
(Class<T> type, S value, Class<? super S> targetType) Binds the supplied annotation to the supplied fixed value.bootstrap
(Constructor<?> constructor) Defines the supplied constructor as a dynamic invocation bootstrap target for delegating advice methods.bootstrap
(Constructor<?> constructor, Advice.BootstrapArgumentResolver.Factory resolverFactory) Defines the supplied constructor as a dynamic invocation bootstrap target for delegating advice methods.Defines the supplied method as a dynamic invocation bootstrap target for delegating advice methods.bootstrap
(Method method, Advice.BootstrapArgumentResolver.Factory resolver) Defines the supplied method as a dynamic invocation bootstrap target for delegating advice methods.bootstrap
(Method method, Advice.BootstrapArgumentResolver.Factory resolver, TypeDescription.Generic.Visitor<? extends TypeDescription.Generic> visitor) Defines the supplied method as a dynamic invocation bootstrap target for delegating advice methods.bootstrap
(MethodDescription.InDefinedShape bootstrap) Defines the supplied method or constructor as a dynamic invocation bootstrap target for delegating advice methods.bootstrap
(MethodDescription.InDefinedShape bootstrap, Advice.BootstrapArgumentResolver.Factory resolverFactory) Defines the supplied method or constructor as a dynamic invocation bootstrap target for delegating advice methods.bootstrap
(MethodDescription.InDefinedShape bootstrap, Advice.BootstrapArgumentResolver.Factory resolverFactory, TypeDescription.Generic.Visitor<? extends TypeDescription.Generic> visitor) Defines the supplied method or constructor as a dynamic invocation bootstrap target for delegating advice methods.Implements advice where every matched method is advised by the given type's advisory methods.Implements advice where every matched method is advised by the given type's advisory methods.to
(Class<?> enterAdvice, Class<?> exitAdvice, ClassFileLocator classFileLocator) Implements advice where every matched method is advised by the given type's advisory methods.to
(Class<?> advice, ClassFileLocator classFileLocator) Implements advice where every matched method is advised by the given type's advisory methods.to
(TypeDescription enterAdvice, TypeDescription exitAdvice) Implements advice where every matched method is advised by the given type's advisory methods.to
(TypeDescription enterAdvice, TypeDescription exitAdvice, ClassFileLocator classFileLocator) Implements advice where every matched method is advised by the given type's advisory methods.to
(TypeDescription advice, ClassFileLocator classFileLocator) Implements advice where every matched method is advised by the given type's advisory methods.with
(Advice.PostProcessor.Factory postProcessorFactory) Adds the supplied post processor factory for advice method post processing.with
(AsmClassReader.Factory classReaderFactory) Defines the factory for producing class readers.
-
Field Details
-
postProcessorFactory
The post processor factory to apply. -
delegatorFactory
The delegator factory to use. -
classReaderFactory
The class reader factory to use. -
offsetMappings
A map containing dynamically computed constant pool values that are mapped by their triggering annotation type.
-
-
Constructor Details
-
WithCustomMapping
protected WithCustomMapping()Creates a new custom mapping builder step without including any custom mappings. -
WithCustomMapping
protected WithCustomMapping(Advice.PostProcessor.Factory postProcessorFactory, Map<Class<? extends Annotation>, Advice.OffsetMapping.Factory<?>> offsetMappings, Advice.Delegator.Factory delegatorFactory, AsmClassReader.Factory classReaderFactory) Creates a new custom mapping builder step with the given custom mappings.- Parameters:
postProcessorFactory
- The post processor factory to apply.offsetMappings
- A map containing dynamically computed constant pool values that are mapped by their triggering annotation type.delegatorFactory
- The delegator factory to use.classReaderFactory
- The class reader factory to use.
-
-
Method Details
-
bind
Binds the supplied annotation to a type constant of the supplied value. Constants can be strings, method handles, method types and any primitive or the valuenull
.- Type Parameters:
T
- The annotation type.- Parameters:
type
- The type of the annotation being bound.value
- The value to bind to the annotation ornull
to bind the parameter type's default value.- Returns:
- A new builder for an advice that considers the supplied annotation type during binding.
-
bind
Binds the supplied annotation to the value of the supplied field. The field must be visible by the instrumented type and must be declared by a super type of the instrumented field.- Type Parameters:
T
- The annotation type.- Parameters:
type
- The type of the annotation being bound.field
- The field to bind to this annotation.- Returns:
- A new builder for an advice that considers the supplied annotation type during binding.
-
bind
public <T extends Annotation> Advice.WithCustomMapping bind(Class<T> type, FieldDescription fieldDescription) Binds the supplied annotation to the value of the supplied field. The field must be visible by the instrumented type and must be declared by a super type of the instrumented field. The binding is defined as read-only and applied static typing.- Type Parameters:
T
- The annotation type.- Parameters:
type
- The type of the annotation being bound.fieldDescription
- The field to bind to this annotation.- Returns:
- A new builder for an advice that considers the supplied annotation type during binding.
-
bind
public <T extends Annotation> Advice.WithCustomMapping bind(Class<T> type, Method method, int index) Binds the supplied annotation to the supplied parameter's argument.- Type Parameters:
T
- The annotation type.- Parameters:
type
- The type of the annotation being bound.method
- The method that defines the parameter.index
- The index of the parameter.- Returns:
- A new builder for an advice that considers the supplied annotation type during binding.
-
bind
public <T extends Annotation> Advice.WithCustomMapping bind(Class<T> type, Constructor<?> constructor, int index) Binds the supplied annotation to the supplied parameter's argument.- Type Parameters:
T
- The annotation type.- Parameters:
type
- The type of the annotation being bound.constructor
- The constructor that defines the parameter.index
- The index of the parameter.- Returns:
- A new builder for an advice that considers the supplied annotation type during binding.
-
bind
public <T extends Annotation> Advice.WithCustomMapping bind(Class<T> type, ParameterDescription parameterDescription) Binds the supplied annotation to the supplied parameter's argument. The binding is declared read-only and applies static typing.- Type Parameters:
T
- The annotation type.- Parameters:
type
- The type of the annotation being bound.parameterDescription
- The parameter for which to bind an argument.- Returns:
- A new builder for an advice that considers the supplied annotation type during binding.
-
bind
Binds the supplied annotation to the supplied type constant.- Type Parameters:
T
- The annotation type.- Parameters:
type
- The type of the annotation being bound.value
- The type constant to bind.- Returns:
- A new builder for an advice that considers the supplied annotation type during binding.
-
bind
Binds the supplied annotation to the supplied type constant.- Type Parameters:
T
- The annotation type.- Parameters:
type
- The type of the annotation being bound.value
- The type constant to bind.- Returns:
- A new builder for an advice that considers the supplied annotation type during binding.
-
bind
Binds the supplied annotation to the supplied enumeration constant.- Type Parameters:
T
- The annotation type.- Parameters:
type
- The type of the annotation being bound.value
- The enumeration constant to bind.- Returns:
- A new builder for an advice that considers the supplied annotation type during binding.
-
bind
public <T extends Annotation> Advice.WithCustomMapping bind(Class<T> type, EnumerationDescription value) Binds the supplied annotation to the supplied enumeration constant.- Type Parameters:
T
- The annotation type.- Parameters:
type
- The type of the annotation being bound.value
- The enumeration constant to bind.- Returns:
- A new builder for an advice that considers the supplied annotation type during binding.
-
bindSerialized
public <T extends Annotation> Advice.WithCustomMapping bindSerialized(Class<T> type, Serializable value) Binds the supplied annotation to the supplied fixed value.- Type Parameters:
T
- The annotation type.- Parameters:
type
- The type of the annotation being bound.value
- The value to bind to this annotation.- Returns:
- A new builder for an advice that considers the supplied annotation type during binding.
-
bindSerialized
public <T extends Annotation,S extends Serializable> Advice.WithCustomMapping bindSerialized(Class<T> type, S value, Class<? super S> targetType) Binds the supplied annotation to the supplied fixed value.- Type Parameters:
T
- The annotation type.S
- The type of the serialized instance.- Parameters:
type
- The type of the annotation being bound.value
- The value to bind to this annotation.targetType
- The type ofvalue
as which the instance should be treated.- Returns:
- A new builder for an advice that considers the supplied annotation type during binding.
-
bindProperty
Binds the supplied annotation to the annotation's property of the specified name.- Type Parameters:
T
- The annotation type.- Parameters:
type
- The type of the annotation being bound.property
- The name of the annotation property to be bound.- Returns:
- A new builder for an advice that considers the supplied annotation during binding.
-
bind
Binds the supplied annotation to the given Java constant.- Type Parameters:
T
- The annotation type.- Parameters:
type
- The type of the annotation being bound.constant
- The Java constant that is bound.- Returns:
- A new builder for an advice that considers the supplied annotation during binding.
-
bind
Binds the supplied annotation to the given Java constant.- Type Parameters:
T
- The annotation type.- Parameters:
type
- The type of the annotation being bound.constant
- The constant value that is bound.- Returns:
- A new builder for an advice that considers the supplied annotation during binding.
-
bind
public <T extends Annotation> Advice.WithCustomMapping bind(Class<T> type, StackManipulation stackManipulation, Type targetType) Binds the supplied annotation to the annotation's property of the specified name.- Type Parameters:
T
- The annotation type.- Parameters:
type
- The type of the annotation being bound.stackManipulation
- The stack manipulation loading the bound value.targetType
- The type of the loaded value.- Returns:
- A new builder for an advice that considers the supplied annotation during binding.
-
bind
public <T extends Annotation> Advice.WithCustomMapping bind(Class<T> type, StackManipulation stackManipulation, TypeDescription.Generic targetType) Binds the supplied annotation to the annotation's property of the specified name.- Type Parameters:
T
- The annotation type.- Parameters:
type
- The type of the annotation being bound.stackManipulation
- The stack manipulation loading the bound value.targetType
- The type of the loaded value.- Returns:
- A new builder for an advice that considers the supplied annotation during binding.
-
bindLambda
public <T extends Annotation> Advice.WithCustomMapping bindLambda(Class<T> type, Constructor<?> constructor, Class<?> functionalInterface) Binds the supplied annotation as a lambda expression via the JVM's lambda metafactory.- Type Parameters:
T
- The annotation type.- Parameters:
type
- The type of the annotation being bound.constructor
- The constructor being bound as the lambda expression's implementation.functionalInterface
- The functional interface that represents the lambda expression.- Returns:
- A new builder for an advice that considers the supplied annotation during binding.
-
bindLambda
public <T extends Annotation> Advice.WithCustomMapping bindLambda(Class<T> type, Constructor<?> constructor, Class<?> functionalInterface, MethodGraph.Compiler methodGraphCompiler) Binds the supplied annotation as a lambda expression via the JVM's lambda metafactory.- Type Parameters:
T
- The annotation type.- Parameters:
type
- The type of the annotation being bound.constructor
- The constructor being bound as the lambda expression's implementation.functionalInterface
- The functional interface that represents the lambda expression.methodGraphCompiler
- The method graph compiler that resolves the functional method of the function interface.- Returns:
- A new builder for an advice that considers the supplied annotation during binding.
-
bindLambda
public <T extends Annotation> Advice.WithCustomMapping bindLambda(Class<T> type, Method method, Class<?> functionalInterface) Binds the supplied annotation as a lambda expression via the JVM's lambda metafactory.- Type Parameters:
T
- The annotation type.- Parameters:
type
- The type of the annotation being bound.method
- The method being bound as the lambda expression's implementation.functionalInterface
- The functional interface that represents the lambda expression.- Returns:
- A new builder for an advice that considers the supplied annotation during binding.
-
bindLambda
public <T extends Annotation> Advice.WithCustomMapping bindLambda(Class<T> type, Method method, Class<?> functionalInterface, MethodGraph.Compiler methodGraphCompiler) Binds the supplied annotation as a lambda expression via the JVM's lambda metafactory.- Type Parameters:
T
- The annotation type.- Parameters:
type
- The type of the annotation being bound.method
- The method being bound as the lambda expression's implementation.functionalInterface
- The functional interface that represents the lambda expression.methodGraphCompiler
- The method graph compiler that resolves the functional method of the function interface.- Returns:
- A new builder for an advice that considers the supplied annotation during binding.
-
bindLambda
public <T extends Annotation> Advice.WithCustomMapping bindLambda(Class<T> type, MethodDescription.InDefinedShape methodDescription, TypeDescription functionalInterface) Binds the supplied annotation as a lambda expression via the JVM's lambda metafactory.- Type Parameters:
T
- The annotation type.- Parameters:
type
- The type of the annotation being bound.methodDescription
- The method or constructor being bound as the lambda expression's implementation.functionalInterface
- The functional interface that represents the lambda expression.- Returns:
- A new builder for an advice that considers the supplied annotation during binding.
-
bindLambda
public <T extends Annotation> Advice.WithCustomMapping bindLambda(Class<T> type, MethodDescription.InDefinedShape methodDescription, TypeDescription functionalInterface, MethodGraph.Compiler methodGraphCompiler) Binds the supplied annotation as a lambda expression via the JVM's lambda metafactory.- Type Parameters:
T
- The annotation type.- Parameters:
type
- The type of the annotation being bound.methodDescription
- The method or constuctor being bound as the lambda expression's implementation.functionalInterface
- The functional interface that represents the lambda expression.methodGraphCompiler
- The method graph compiler that resolves the functional method of the function interface.- Returns:
- A new builder for an advice that considers the supplied annotation during binding.
-
bindDynamic
public <T extends Annotation> Advice.WithCustomMapping bindDynamic(Class<T> type, Method bootstrapMethod, Object... constant) Binds the supplied annotation to a dynamically bootstrapped value.- Type Parameters:
T
- The annotation type.- Parameters:
type
- The type of the annotation being bound.bootstrapMethod
- The bootstrap method returning the call site.constant
- The arguments supplied to the bootstrap method.- Returns:
- A new builder for an advice that considers the supplied annotation during binding.
-
bindDynamic
public <T extends Annotation> Advice.WithCustomMapping bindDynamic(Class<T> type, Method bootstrapMethod, List<?> constants) Binds the supplied annotation to a dynamically bootstrapped value.- Type Parameters:
T
- The annotation type.- Parameters:
type
- The type of the annotation being bound.bootstrapMethod
- The bootstrap method returning the call site.constants
- The arguments supplied to the bootstrap method.- Returns:
- A new builder for an advice that considers the supplied annotation during binding.
-
bindDynamic
public <T extends Annotation> Advice.WithCustomMapping bindDynamic(Class<T> type, Constructor<?> bootstrapMethod, Object... constant) Binds the supplied annotation to a dynamically bootstrapped value.- Type Parameters:
T
- The annotation type.- Parameters:
type
- The type of the annotation being bound.bootstrapMethod
- The bootstrap constructor returning the call site.constant
- The arguments supplied to the bootstrap method.- Returns:
- A new builder for an advice that considers the supplied annotation during binding.
-
bindDynamic
public <T extends Annotation> Advice.WithCustomMapping bindDynamic(Class<T> type, Constructor<?> bootstrapMethod, List<?> constants) Binds the supplied annotation to a dynamically bootstrapped value.- Type Parameters:
T
- The annotation type.- Parameters:
type
- The type of the annotation being bound.bootstrapMethod
- The bootstrap constructor returning the call site.constants
- The arguments supplied to the bootstrap method.- Returns:
- A new builder for an advice that considers the supplied annotation during binding.
-
bindDynamic
public <T extends Annotation> Advice.WithCustomMapping bindDynamic(Class<T> type, MethodDescription.InDefinedShape bootstrapMethod, Object... constant) Binds the supplied annotation to a dynamically bootstrapped value.- Type Parameters:
T
- The annotation type.- Parameters:
type
- The type of the annotation being bound.bootstrapMethod
- The bootstrap method or constructor returning the call site.constant
- The arguments supplied to the bootstrap method.- Returns:
- A new builder for an advice that considers the supplied annotation during binding.
-
bindDynamic
public <T extends Annotation> Advice.WithCustomMapping bindDynamic(Class<T> type, MethodDescription.InDefinedShape bootstrapMethod, List<?> constants) Binds the supplied annotation to a dynamically bootstrapped value.- Type Parameters:
T
- The annotation type.- Parameters:
type
- The type of the annotation being bound.bootstrapMethod
- The bootstrap method or constructor returning the call site.constants
- The arguments supplied to the bootstrap method.- Returns:
- A new builder for an advice that considers the supplied annotation during binding.
-
bind
public <T extends Annotation> Advice.WithCustomMapping bind(Class<T> type, Advice.OffsetMapping offsetMapping) Binds the supplied annotation to the annotation's property of the specified name.- Type Parameters:
T
- The annotation type.- Parameters:
type
- The type of the annotation being bound.offsetMapping
- The offset mapping being bound.- Returns:
- A new builder for an advice that considers the supplied annotation during binding.
-
bind
Binds an annotation to a dynamically computed value. Whenever theAdvice
component discovers the given annotation on a parameter of an advice method, the dynamic value is asked to provide a value that is then assigned to the parameter in question.- Parameters:
offsetMapping
- The dynamic value that is computed for binding the parameter to a value.- Returns:
- A new builder for an advice that considers the supplied annotation type during binding.
-
bootstrap
Defines the supplied constructor as a dynamic invocation bootstrap target for delegating advice methods. The bootstrap method arguments are:- A
java.lang.invoke.MethodHandles.Lookup
representing the source method. - A
String
representing the constructor's internal name<init>
. - A
java.lang.invoke.MethodType
representing the type that is requested for binding. - A
String
of the target's binary class name. - A
int
with value0
for an enter advice and {code 1} for an exist advice. - A
Class
representing the class implementing the instrumented method. - A
String
with the name of the instrumented method. - A
java.lang.invoke.MethodHandle
representing the instrumented method unless the target is the type's static initializer.
- Parameters:
constructor
- The bootstrap constructor.- Returns:
- A new builder for an advice that uses the supplied constructor for bootstrapping.
- A
-
bootstrap
public Advice.WithCustomMapping bootstrap(Constructor<?> constructor, Advice.BootstrapArgumentResolver.Factory resolverFactory) Defines the supplied constructor as a dynamic invocation bootstrap target for delegating advice methods. The bootstrap method arguments are provided explicitly by the supplied resolver.- Parameters:
constructor
- The bootstrap constructor.resolverFactory
- A resolver factory to provide the arguments to the bootstrap method.- Returns:
- A new builder for an advice that uses the supplied constructor for bootstrapping.
-
bootstrap
Defines the supplied method as a dynamic invocation bootstrap target for delegating advice methods. The bootstrap method arguments are:- A
java.lang.invoke.MethodHandles.Lookup
representing the source method. - A
String
representing the method's name. - A
java.lang.invoke.MethodType
representing the type that is requested for binding. - A
String
of the target's binary class name. - A
int
with value0
for an enter advice and {code 1} for an exist advice. - A
Class
representing the class implementing the instrumented method. - A
String
with the name of the instrumented method. - A
java.lang.invoke.MethodHandle
representing the instrumented method unless the target is the type's static initializer.
- Parameters:
method
- The bootstrap method.- Returns:
- A new builder for an advice that uses the supplied method for bootstrapping.
- A
-
bootstrap
public Advice.WithCustomMapping bootstrap(Method method, Advice.BootstrapArgumentResolver.Factory resolver) Defines the supplied method as a dynamic invocation bootstrap target for delegating advice methods. The bootstrap method arguments are provided explicitly by the supplied resolver.- Parameters:
method
- The bootstrap method.resolver
- A resolver to provide the arguments to the bootstrap method.- Returns:
- A new builder for an advice that uses the supplied method for bootstrapping.
-
bootstrap
public Advice.WithCustomMapping bootstrap(Method method, Advice.BootstrapArgumentResolver.Factory resolver, TypeDescription.Generic.Visitor<? extends TypeDescription.Generic> visitor) Defines the supplied method as a dynamic invocation bootstrap target for delegating advice methods. The bootstrap method arguments are provided explicitly by the supplied resolver.- Parameters:
method
- The bootstrap method.resolver
- A resolver 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:
- A new builder for an advice that uses the supplied method for bootstrapping.
-
bootstrap
Defines the supplied method or constructor as a dynamic invocation bootstrap target for delegating advice methods. The bootstrap method arguments are:- A
java.lang.invoke.MethodHandles.Lookup
representing the source method. - A
String
representing the method's name or constructor's internal name<init>
. - A
java.lang.invoke.MethodType
representing the type that is requested for binding. - A
String
of the target's binary class name. - A
int
with value0
for an enter advice and {code 1} for an exist advice. - A
Class
representing the class implementing the instrumented method. - A
String
with the name of the instrumented method. - A
java.lang.invoke.MethodHandle
representing the instrumented method unless the target is the type's static initializer.
- Parameters:
bootstrap
- The bootstrap method or constructor.- Returns:
- A new builder for an advice that uses the supplied method or constructor for bootstrapping.
- A
-
bootstrap
public Advice.WithCustomMapping bootstrap(MethodDescription.InDefinedShape bootstrap, Advice.BootstrapArgumentResolver.Factory resolverFactory) Defines the supplied method or constructor as a dynamic invocation bootstrap target for delegating advice methods. The bootstrap method arguments are provided explicitly by the supplied resolver.- Parameters:
bootstrap
- The bootstrap method or constructor.resolverFactory
- A factory for a resolver to provide arguments to the bootstrap method.- Returns:
- A new builder for an advice that uses the supplied method or constructor for bootstrapping.
-
bootstrap
public Advice.WithCustomMapping bootstrap(MethodDescription.InDefinedShape bootstrap, Advice.BootstrapArgumentResolver.Factory resolverFactory, TypeDescription.Generic.Visitor<? extends TypeDescription.Generic> visitor) Defines the supplied method or constructor as a dynamic invocation bootstrap target for delegating advice methods. The bootstrap method arguments are provided explicitly by the supplied resolver.- Parameters:
bootstrap
- The bootstrap method or constructor.resolverFactory
- A factory for a resolver to provide 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:
- A new builder for an advice that uses the supplied method or constructor for bootstrapping.
-
with
Adds the supplied post processor factory for advice method post processing.- Parameters:
postProcessorFactory
- The post processor factory to add.- Returns:
- A new builder for an advice that applies the supplied post processor factory.
-
with
Defines the factory for producing class readers.- Parameters:
classReaderFactory
- The class reader factory to use.- Returns:
- A new builder for an advice that applies the supplied post processor factory.
-
to
Implements advice where every matched method is advised by the given type's advisory methods. The advices binary representation is accessed by querying the class loader of the supplied class for a class file.- Parameters:
advice
- The type declaring the advice.- Returns:
- A method visitor wrapper representing the supplied advice.
-
to
Implements advice where every matched method is advised by the given type's advisory methods.- Parameters:
advice
- The type declaring the advice.classFileLocator
- The class file locator for locating the advisory class's class file.- Returns:
- A method visitor wrapper representing the supplied advice.
-
to
Implements advice where every matched method is advised by the given type's advisory methods.- Parameters:
advice
- A description of the type declaring the advice.classFileLocator
- The class file locator for locating the advisory class's class file.- Returns:
- A method visitor wrapper representing the supplied advice.
-
to
Implements advice where every matched method is advised by the given type's advisory methods. The advices binary representation is accessed by querying the class loader of the supplied class for a class file.- Parameters:
enterAdvice
- The type declaring the enter advice.exitAdvice
- The type declaring the exit advice.- Returns:
- A method visitor wrapper representing the supplied advice.
-
to
Implements advice where every matched method is advised by the given type's advisory methods.- Parameters:
enterAdvice
- The type declaring the enter advice.exitAdvice
- The type declaring the exit advice.classFileLocator
- The class file locator for locating the advisory class's class file.- Returns:
- A method visitor wrapper representing the supplied advice.
-
to
Implements advice where every matched method is advised by the given type's advisory methods. Using this method, a non-operational class file locator is specified for the advice target. This implies that only advice targets with the inline target set tofalse
are resolvable by the returned instance.- Parameters:
enterAdvice
- The type declaring the enter advice.exitAdvice
- The type declaring the exit advice.- Returns:
- A method visitor wrapper representing the supplied advice.
-
to
public Advice to(TypeDescription enterAdvice, TypeDescription exitAdvice, ClassFileLocator classFileLocator) Implements advice where every matched method is advised by the given type's advisory methods.- Parameters:
enterAdvice
- The type declaring the enter advice.exitAdvice
- The type declaring the exit advice.classFileLocator
- The class file locator for locating the advisory class's class file.- Returns:
- A method visitor wrapper representing the supplied advice.
-