Class MemberSubstitution.WithoutSpecification.ForMatchedMethod
java.lang.Object
net.bytebuddy.asm.MemberSubstitution.WithoutSpecification<MemberSubstitution.Target.ForMember>
net.bytebuddy.asm.MemberSubstitution.WithoutSpecification.ForMatchedMethod
- Enclosing class:
MemberSubstitution.WithoutSpecification<T extends MemberSubstitution.Target>
@Enhance
public static class MemberSubstitution.WithoutSpecification.ForMatchedMethod
extends MemberSubstitution.WithoutSpecification<MemberSubstitution.Target.ForMember>
Describes a member substitution that requires a specification for how to replace a method or constructor.
-
Nested Class Summary
Nested classes/interfaces inherited from class MemberSubstitution.WithoutSpecification
MemberSubstitution.WithoutSpecification.ForMatchedByteCodeElement, MemberSubstitution.WithoutSpecification.ForMatchedDynamicInvocation, MemberSubstitution.WithoutSpecification.ForMatchedField, MemberSubstitution.WithoutSpecification.ForMatchedMethod -
Field Summary
FieldsModifier and TypeFieldDescriptionprivate final booleantrueif this specification includessuperinvocations.private final booleantrueif this specification includes virtual invocations.private final ElementMatcher<? super MethodDescription> A matcher for any method or constructor that should be substituted.Fields inherited from class MemberSubstitution.WithoutSpecification
failIfNoMatch, methodGraphCompiler, replacementFactory, strict, typePoolResolver -
Constructor Summary
ConstructorsModifierConstructorDescriptionprotectedForMatchedMethod(MethodGraph.Compiler methodGraphCompiler, MemberSubstitution.TypePoolResolver typePoolResolver, boolean strict, boolean failIfNoMatch, MemberSubstitution.Replacement.Factory replacementFactory, ElementMatcher<? super MethodDescription> matcher) Creates a new member substitution for a matched method that requires a specification for how to perform a substitution.protectedForMatchedMethod(MethodGraph.Compiler methodGraphCompiler, MemberSubstitution.TypePoolResolver typePoolResolver, boolean strict, boolean failIfNoMatch, MemberSubstitution.Replacement.Factory replacementFactory, ElementMatcher<? super MethodDescription> matcher, boolean includeVirtualCalls, boolean includeSuperCalls) Creates a new member substitution for a matched method that requires a specification for how to perform a substitution. -
Method Summary
Modifier and TypeMethodDescriptionLimits the substituted method calls to method calls that invoke a method as asupercall.Limits the substituted method calls to method calls that invoke a method virtually (as opposed to asuperinvocation).replaceWith(MemberSubstitution.Substitution.Factory<? super MemberSubstitution.Target.ForMember> substitutionFactory) Replaces any interaction with the supplied substitution.
-
Field Details
-
matcher
A matcher for any method or constructor that should be substituted. -
includeVirtualCalls
private final boolean includeVirtualCallstrueif this specification includes virtual invocations. -
includeSuperCalls
private final boolean includeSuperCallstrueif this specification includessuperinvocations.
-
-
Constructor Details
-
ForMatchedMethod
protected ForMatchedMethod(MethodGraph.Compiler methodGraphCompiler, MemberSubstitution.TypePoolResolver typePoolResolver, boolean strict, boolean failIfNoMatch, MemberSubstitution.Replacement.Factory replacementFactory, ElementMatcher<? super MethodDescription> matcher) Creates a new member substitution for a matched method that requires a specification for how to perform a substitution.- Parameters:
methodGraphCompiler- The method graph compiler to use.typePoolResolver- The type pool resolver to use.strict-trueif the method processing should be strict where an exception is raised if a member cannot be found.failIfNoMatch-trueif the instrumentation should fail if applied to a method without match.replacementFactory- The replacement factory to use.matcher- A matcher for any method or constructor that should be substituted.
-
ForMatchedMethod
protected ForMatchedMethod(MethodGraph.Compiler methodGraphCompiler, MemberSubstitution.TypePoolResolver typePoolResolver, boolean strict, boolean failIfNoMatch, MemberSubstitution.Replacement.Factory replacementFactory, ElementMatcher<? super MethodDescription> matcher, boolean includeVirtualCalls, boolean includeSuperCalls) Creates a new member substitution for a matched method that requires a specification for how to perform a substitution.- Parameters:
methodGraphCompiler- The method graph compiler to use.typePoolResolver- The type pool resolver to use.strict-trueif the method processing should be strict where an exception is raised if a member cannot be found.failIfNoMatch-trueif the instrumentation should fail if applied to a method without match.replacementFactory- The replacement factory to use.matcher- A matcher for any method or constructor that should be substituted.includeVirtualCalls-trueif this specification includes virtual invocations.includeSuperCalls-trueif this specification includessuperinvocations.
-
-
Method Details
-
onVirtualCall
Limits the substituted method calls to method calls that invoke a method virtually (as opposed to asuperinvocation).- Returns:
- This specification where only virtual methods are matched if they are not invoked as a virtual call.
-
onSuperCall
Limits the substituted method calls to method calls that invoke a method as asupercall.- Returns:
- This specification where only virtual methods are matched if they are not invoked as a super call.
-
replaceWith
public MemberSubstitution replaceWith(MemberSubstitution.Substitution.Factory<? super MemberSubstitution.Target.ForMember> substitutionFactory) Replaces any interaction with the supplied substitution.- Specified by:
replaceWithin classMemberSubstitution.WithoutSpecification<MemberSubstitution.Target.ForMember>- Parameters:
substitutionFactory- The substitution factory to use for creating the applied substitution.- Returns:
- A member substitution that replaces any matched byte code element with the supplied substitution.
-