Class MemberSubstitution.Replacement.ForElementMatchers
java.lang.Object
net.bytebuddy.asm.MemberSubstitution.Replacement.ForElementMatchers
- All Implemented Interfaces:
MemberSubstitution.Replacement
- Enclosing interface:
MemberSubstitution.Replacement
@Enhance
public static class MemberSubstitution.Replacement.ForElementMatchers
extends Object
implements MemberSubstitution.Replacement
A replacement that substitutes a member based on a row of element matchers.
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionprotected static classA factory for creating a replacement that chooses members based on a row of element matchers.Nested classes/interfaces inherited from interface MemberSubstitution.Replacement
MemberSubstitution.Replacement.Binding, MemberSubstitution.Replacement.ForDynamicInvocation, MemberSubstitution.Replacement.ForElementMatchers, MemberSubstitution.Replacement.ForFirstBinding, MemberSubstitution.Replacement.InvocationType, MemberSubstitution.Replacement.NoOp -
Field Summary
FieldsModifier and TypeFieldDescriptionprivate final ElementMatcher<? super FieldDescription> The field matcher to consider when discovering fields.private final booleantrueif super method calls should be matched.private final booleantrueif virtual method calls should be matched.private final booleantrueif field reading access should be matched.private final booleantrueif field writing access should be matched.private final ElementMatcher<? super MethodDescription> The method matcher to consider when discovering methods.private final MemberSubstitution.Substitution<? super MemberSubstitution.Target.ForMember> The substitution to trigger if a member is matched. -
Constructor Summary
ConstructorsModifierConstructorDescriptionprotectedForElementMatchers(ElementMatcher<? super FieldDescription> fieldMatcher, ElementMatcher<? super MethodDescription> methodMatcher, boolean matchFieldRead, boolean matchFieldWrite, boolean includeVirtualCalls, boolean includeSuperCalls, MemberSubstitution.Substitution<? super MemberSubstitution.Target.ForMember> substitution) Creates a new replacement that triggers a substitution based on a row of matchers. -
Method Summary
Modifier and TypeMethodDescriptionbind(TypeDescription instrumentedType, MethodDescription instrumentedMethod, TypeDescription typeDescription, FieldDescription fieldDescription, boolean writeAccess) Binds this replacement for a field that was discovered.bind(TypeDescription instrumentedType, MethodDescription instrumentedMethod, TypeDescription typeDescription, MethodDescription methodDescription, MemberSubstitution.Replacement.InvocationType invocationType) Binds this replacement for a field that was discovered.bind(TypeDescription instrumentedType, MethodDescription instrumentedMethod, JavaConstant.MethodHandle methodHandle, JavaConstant.MethodType methodType, String name, List<JavaConstant> constants) Binds this replacement for a dynamic method invocation that was discovered.
-
Field Details
-
fieldMatcher
The field matcher to consider when discovering fields. -
methodMatcher
The method matcher to consider when discovering methods. -
matchFieldRead
private final boolean matchFieldReadtrueif field reading access should be matched. -
matchFieldWrite
private final boolean matchFieldWritetrueif field writing access should be matched. -
includeVirtualCalls
private final boolean includeVirtualCallstrueif virtual method calls should be matched. -
includeSuperCalls
private final boolean includeSuperCallstrueif super method calls should be matched. -
substitution
private final MemberSubstitution.Substitution<? super MemberSubstitution.Target.ForMember> substitutionThe substitution to trigger if a member is matched.
-
-
Constructor Details
-
ForElementMatchers
protected ForElementMatchers(ElementMatcher<? super FieldDescription> fieldMatcher, ElementMatcher<? super MethodDescription> methodMatcher, boolean matchFieldRead, boolean matchFieldWrite, boolean includeVirtualCalls, boolean includeSuperCalls, MemberSubstitution.Substitution<? super MemberSubstitution.Target.ForMember> substitution) Creates a new replacement that triggers a substitution based on a row of matchers.- Parameters:
fieldMatcher- The field matcher to consider when discovering fields.methodMatcher- The method matcher to consider when discovering methods.matchFieldRead-trueif field reading access should be matched.matchFieldWrite-trueif field writing access should be matched.includeVirtualCalls-trueif virtual method calls should be matched.includeSuperCalls-trueif super method calls should be matched.substitution- The substitution to trigger if a member is matched.
-
-
Method Details
-
bind
public MemberSubstitution.Replacement.Binding bind(TypeDescription instrumentedType, MethodDescription instrumentedMethod, TypeDescription typeDescription, FieldDescription fieldDescription, boolean writeAccess) Binds this replacement for a field that was discovered.- Specified by:
bindin interfaceMemberSubstitution.Replacement- Parameters:
instrumentedType- The instrumented type.instrumentedMethod- The instrumented method.typeDescription- The type on which the field was read.fieldDescription- The field that was discovered.writeAccess-trueif this field was written to.- Returns:
- A binding for the discovered field access.
-
bind
public MemberSubstitution.Replacement.Binding bind(TypeDescription instrumentedType, MethodDescription instrumentedMethod, TypeDescription typeDescription, MethodDescription methodDescription, MemberSubstitution.Replacement.InvocationType invocationType) Binds this replacement for a field that was discovered.- Specified by:
bindin interfaceMemberSubstitution.Replacement- Parameters:
instrumentedType- The instrumented type.FieldDescriptioninstrumentedMethod- The instrumented method.typeDescription- The type on which the method was invoked.methodDescription- The method that was discovered.invocationType- The invocation type for this method.- Returns:
- A binding for the discovered method invocation.
-
bind
public MemberSubstitution.Replacement.Binding bind(TypeDescription instrumentedType, MethodDescription instrumentedMethod, JavaConstant.MethodHandle methodHandle, JavaConstant.MethodType methodType, String name, List<JavaConstant> constants) Binds this replacement for a dynamic method invocation that was discovered.- Specified by:
bindin interfaceMemberSubstitution.Replacement- Parameters:
instrumentedType- The instrumented type.FieldDescriptioninstrumentedMethod- The instrumented method.methodHandle- The method handle of the bootstrap method.methodType- The type of the method that is bound.name- The name of the method that is bound.constants- The constant arguments to the bootstrap method.- Returns:
- A binding for the discovered method invocation.
-