Package net.bytebuddy.asm
Class MemberSubstitution.WithoutSpecification.ForMatchedMethod
- java.lang.Object
-
- net.bytebuddy.asm.MemberSubstitution.WithoutSpecification
-
- net.bytebuddy.asm.MemberSubstitution.WithoutSpecification.ForMatchedMethod
-
- Enclosing class:
- MemberSubstitution.WithoutSpecification
@Enhance public static class MemberSubstitution.WithoutSpecification.ForMatchedMethod extends MemberSubstitution.WithoutSpecification
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 net.bytebuddy.asm.MemberSubstitution.WithoutSpecification
MemberSubstitution.WithoutSpecification.ForMatchedByteCodeElement, MemberSubstitution.WithoutSpecification.ForMatchedField, MemberSubstitution.WithoutSpecification.ForMatchedMethod
-
-
Field Summary
Fields Modifier and Type Field Description private boolean
includeSuperCalls
true
if this specification includessuper
invocations.private boolean
includeVirtualCalls
true
if this specification includes virtual invocations.private ElementMatcher<? super MethodDescription>
matcher
A matcher for any method or constructor that should be substituted.-
Fields inherited from class net.bytebuddy.asm.MemberSubstitution.WithoutSpecification
methodGraphCompiler, replacementFactory, strict, typePoolResolver
-
-
Constructor Summary
Constructors Modifier Constructor Description protected
ForMatchedMethod(MethodGraph.Compiler methodGraphCompiler, MemberSubstitution.TypePoolResolver typePoolResolver, boolean strict, 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.protected
ForMatchedMethod(MethodGraph.Compiler methodGraphCompiler, MemberSubstitution.TypePoolResolver typePoolResolver, boolean strict, 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
All Methods Instance Methods Concrete Methods Modifier and Type Method Description MemberSubstitution.WithoutSpecification
onSuperCall()
Limits the substituted method calls to method calls that invoke a method as asuper
call.MemberSubstitution.WithoutSpecification
onVirtualCall()
Limits the substituted method calls to method calls that invoke a method virtually (as opposed to asuper
invocation).MemberSubstitution
replaceWith(MemberSubstitution.Substitution.Factory substitutionFactory)
Replaces any interaction with the supplied substitution.-
Methods inherited from class net.bytebuddy.asm.MemberSubstitution.WithoutSpecification
replaceWith, replaceWith, replaceWith, replaceWith, replaceWithChain, replaceWithChain, replaceWithField, replaceWithInstrumentedMethod, replaceWithMethod, replaceWithMethod, stub
-
-
-
-
Field Detail
-
matcher
private final ElementMatcher<? super MethodDescription> matcher
A matcher for any method or constructor that should be substituted.
-
includeVirtualCalls
private final boolean includeVirtualCalls
true
if this specification includes virtual invocations.
-
includeSuperCalls
private final boolean includeSuperCalls
true
if this specification includessuper
invocations.
-
-
Constructor Detail
-
ForMatchedMethod
protected ForMatchedMethod(MethodGraph.Compiler methodGraphCompiler, MemberSubstitution.TypePoolResolver typePoolResolver, boolean strict, 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
-true
if the method processing should be strict where an exception is raised if a member cannot be found.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, 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
-true
if the method processing should be strict where an exception is raised if a member cannot be found.replacementFactory
- The replacement factory to use.matcher
- A matcher for any method or constructor that should be substituted.includeVirtualCalls
-true
if this specification includes virtual invocations.includeSuperCalls
-true
if this specification includessuper
invocations.
-
-
Method Detail
-
onVirtualCall
public MemberSubstitution.WithoutSpecification onVirtualCall()
Limits the substituted method calls to method calls that invoke a method virtually (as opposed to asuper
invocation).- Returns:
- This specification where only virtual methods are matched if they are not invoked as a virtual call.
-
onSuperCall
public MemberSubstitution.WithoutSpecification onSuperCall()
Limits the substituted method calls to method calls that invoke a method as asuper
call.- 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 substitutionFactory)
Replaces any interaction with the supplied substitution.- Specified by:
replaceWith
in classMemberSubstitution.WithoutSpecification
- 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.
-
-