Substitutes field access, method invocations or constructor calls within a method's body.
Note
This substitution must not be used to match constructor calls to an instrumented class's super constructor invocation from within a constructor. Matching such constructors will result in an invalid stack and a verification error.
Note
This visitor will compute the required stack size on a best effort basis. For allocating an optimal stack size, ASM needs to be configured to compute the stack size.
Important Note
This component relies on using a TypePool for locating types within method bodies. Within a redefinition
or a rebasement, this type pool normally resolved correctly by Byte Buddy. When subclassing a type, the type pool must be set
explicitly, using net. or any similar method. It is however not normally
necessary to use this component when subclassing a type where methods are only defined explicitly.
| Modifier and Type | Class and Description |
|---|---|
| public static @interface | MemberSubstitution.AllArguments
Assigns an array containing all arguments of the targeted element to the annotated parameter. |
| public static @interface | MemberSubstitution.Argument
Indicates that the annotated parameter should be mapped to the parameter with index |
| public static @interface | MemberSubstitution.Current
Indicates that the annotated parameter should be assigned the value of the result that was yielded by the previous chain expression. |
| public static @interface | MemberSubstitution.FieldGetterHandle
Indicates that the annotated parameter should be mapped to a |
| public static @interface | MemberSubstitution.FieldSetterHandle
Indicates that the annotated parameter should be mapped to a |
| public static @interface | MemberSubstitution.FieldValue
Indicates that the annotated parameter should be mapped to a field in the scope of the instrumented type. |
| public static @interface | MemberSubstitution.Origin
Indicates that the annotated parameter should be mapped to a representation of the substituted element or instrumented method. |
| protected static interface | MemberSubstitution.Replacement
A replacement combines a |
| public static @interface | MemberSubstitution.SelfCallHandle
Indicates that the annotated parameter should load a |
| public static enum | MemberSubstitution.Source
Identifies the source of an instruction that might describe a value of the substituted element or the instrumented method. |
| public static @interface | MemberSubstitution.StubValue
Indicates that the annotated parameter should always return a boxed version of the instrumented method's return value
(i.e. |
| protected static class | MemberSubstitution.SubstitutingMethodVisitor
A method visitor that applies a substitution for matched methods. |
| public static interface | MemberSubstitution.Substitution
A substitution replaces or enhances an interaction with a field or method within an instrumented method. |
| public static @interface | MemberSubstitution.This
Indicates that the annotated parameter should be mapped to the |
| public static interface | MemberSubstitution.TypePoolResolver
A type pool resolver is responsible for resolving a |
| public static @interface | MemberSubstitution.Unused
Indicates that the annotated parameter should always return a default value (i.e. |
| public abstract static class | MemberSubstitution.WithoutSpecification
A member substitution that lacks a specification for how to substitute the matched members references within a method body. |
| Modifier and Type | Field and Description |
|---|---|
| private final boolean | failIfNoMatch
|
| private final MethodGraph. | methodGraphCompiler
The method graph compiler to use. |
| private final MemberSubstitution. | replacementFactory
The replacement factory to use. |
| private final boolean | strict
|
| protected static final int | THIS_REFERENCE
The index of the this reference within a non-static method. |
| private final MemberSubstitution. | typePoolResolver
The type pool resolver to use. |
| Access | Constructor and Description |
|---|---|
| protected | MemberSubstitution(boolean
true if the method processing should be strict where an exception is raised if a member cannot be found.Creates a default member substitution. |
| protected | MemberSubstitution(MethodGraph.
The method graph compiler to use. methodGraphCompiler,The type pool resolver to use. typePoolResolver,true if the method processing should be strict where an exception is raised if a member cannot be found.true if the instrumentation should fail if applied to a method without match.The replacement factory to use. replacementFactoryCreates a new member substitution. |
| Modifier and Type | Method and Description |
|---|---|
| public MemberSubstitution. | Returns: A specification that allows to determine how to substitute any constructor invocations that match the supplied matcher.The matcher to determine what constructors to substitute. matcher)Substitutes any constructor invocation that matches the given matcher. |
| public MemberSubstitution. | Returns: A specification that allows to determine how to substitute any interaction with byte code elements that match the supplied matcher.The matcher to determine what access to byte code elements to substitute. matcher)Substitutes any interaction with a field or method that matches the given matcher. |
| public MemberSubstitution | Returns: A new instance of this member substitution that fails if applied on a method without a match.true if the instrumentation should fail if applied to a method without match.Specifies if this substitution should fail if applied on a method without a match. |
| public MemberSubstitution. | Returns: A specification that allows to determine how to substitute any field access that match the supplied matcher.The matcher to determine what fields to substitute. matcher)Substitutes any field access that matches the given matcher. |
| public MemberSubstitution. | Returns: A specification that allows to determine how to substitute any constructor invocations that match the supplied matcher.The matcher to determine what method or constructors to substitute. matcher)Substitutes any method or constructor invocation that matches the given matcher. |
| public MemberSubstitution. | Returns: A specification that allows to determine how to substitute any method invocations that match the supplied matcher.The matcher to determine what methods to substitute. matcher)Substitutes any method invocation that matches the given matcher. |
| public AsmVisitorWrapper. | Returns: An ASM visitor wrapper that applies all specified substitutions for any matched method.The matcher to determine this substitutions application. matcher)Applies this member substitution to any method that matches the supplied matcher. |
| public static MemberSubstitution | Returns: A relaxed member substitution.Creates a member substitution that skips any unresolvable fields or methods that are referenced within a method body. |
| public static MemberSubstitution | Returns: A strict member substitution.Creates a member substitution that requires the resolution of all fields and methods that are referenced within a method body. |
| public MemberSubstitution | Returns: A new member substitution that is equal to this but uses the specified method graph compiler.The method graph compiler to use. methodGraphCompilerSpecifies the use of a specific method graph compiler for the resolution of virtual methods. |
| public MemberSubstitution | Returns: A new instance of this member substitution that uses the supplied type pool resolver.The type pool resolver to use. typePoolResolverSpecifies a type pool resolver to be used for locating members. |
| public MethodVisitor | wrap(TypeDescription
The instrumented type. instrumentedType, MethodDescription The method that is currently being defined. instrumentedMethod, MethodVisitor The original field visitor that defines the given method. methodVisitor, Implementation.The implementation context to use. implementationContext,The type pool to use. typePool, int The ASM writerFlags, int net. reader flags to consider.The ASM readerFlags)net. reader flags to consider.Implements net. |