Package net.bytebuddy.agent.builder
Class AgentBuilder.RawMatcher.ForElementMatchers
java.lang.Object
net.bytebuddy.agent.builder.AgentBuilder.RawMatcher.ForElementMatchers
- All Implemented Interfaces:
AgentBuilder.RawMatcher
- Enclosing interface:
AgentBuilder.RawMatcher
@Enhance
public static class AgentBuilder.RawMatcher.ForElementMatchers
extends Object
implements AgentBuilder.RawMatcher
A raw matcher implementation that checks a
TypeDescription
and its ClassLoader against two suitable matchers in order to determine if the matched
type should be instrumented.-
Nested Class Summary
Nested classes/interfaces inherited from interface net.bytebuddy.agent.builder.AgentBuilder.RawMatcher
AgentBuilder.RawMatcher.Conjunction, AgentBuilder.RawMatcher.Disjunction, AgentBuilder.RawMatcher.ForElementMatchers, AgentBuilder.RawMatcher.ForLoadState, AgentBuilder.RawMatcher.ForResolvableTypes, AgentBuilder.RawMatcher.Inversion, AgentBuilder.RawMatcher.Trivial -
Field Summary
FieldsModifier and TypeFieldDescriptionprivate final ElementMatcher<? super ClassLoader> The class loader matcher to apply to aClassLoader.private final ElementMatcher<? super JavaModule> A module matcher to apply to ajava.lang.Module.private final ElementMatcher<? super TypeDescription> The type matcher to apply to aTypeDescription. -
Constructor Summary
ConstructorsConstructorDescriptionForElementMatchers(ElementMatcher<? super TypeDescription> typeMatcher) Creates a newAgentBuilder.RawMatcherthat only matches the suppliedTypeDescriptionagainst a supplied matcher.ForElementMatchers(ElementMatcher<? super TypeDescription> typeMatcher, ElementMatcher<? super ClassLoader> classLoaderMatcher) Creates a newAgentBuilder.RawMatcherthat only matches the suppliedTypeDescriptionand itsClassLoaderagainst two matcher in order to decided if an instrumentation should be conducted.ForElementMatchers(ElementMatcher<? super TypeDescription> typeMatcher, ElementMatcher<? super ClassLoader> classLoaderMatcher, ElementMatcher<? super JavaModule> moduleMatcher) Creates a newAgentBuilder.RawMatcherthat only matches the suppliedTypeDescription, itsClassLoaderand module against element suitable matchers. -
Method Summary
Modifier and TypeMethodDescriptionbooleanmatches(TypeDescription typeDescription, ClassLoader classLoader, JavaModule module, Class<?> classBeingRedefined, ProtectionDomain protectionDomain) Decides if the giventypeDescriptionshould be instrumented with the entailedAgentBuilder.Transformers.
-
Field Details
-
typeMatcher
The type matcher to apply to aTypeDescription. -
classLoaderMatcher
The class loader matcher to apply to aClassLoader. -
moduleMatcher
A module matcher to apply to ajava.lang.Module.
-
-
Constructor Details
-
ForElementMatchers
Creates a newAgentBuilder.RawMatcherthat only matches the suppliedTypeDescriptionagainst a supplied matcher.- Parameters:
typeMatcher- The type matcher to apply to aTypeDescription.
-
ForElementMatchers
public ForElementMatchers(ElementMatcher<? super TypeDescription> typeMatcher, ElementMatcher<? super ClassLoader> classLoaderMatcher) Creates a newAgentBuilder.RawMatcherthat only matches the suppliedTypeDescriptionand itsClassLoaderagainst two matcher in order to decided if an instrumentation should be conducted.- Parameters:
typeMatcher- The type matcher to apply to aTypeDescription.classLoaderMatcher- The class loader matcher to apply to aClassLoader.
-
ForElementMatchers
public ForElementMatchers(ElementMatcher<? super TypeDescription> typeMatcher, ElementMatcher<? super ClassLoader> classLoaderMatcher, ElementMatcher<? super JavaModule> moduleMatcher) Creates a newAgentBuilder.RawMatcherthat only matches the suppliedTypeDescription, itsClassLoaderand module against element suitable matchers.- Parameters:
typeMatcher- The type matcher to apply to aTypeDescription.classLoaderMatcher- The class loader matcher to apply to aClassLoader.moduleMatcher- A module matcher to apply to ajava.lang.Module.
-
-
Method Details
-
matches
public boolean matches(TypeDescription typeDescription, @MaybeNull ClassLoader classLoader, @MaybeNull JavaModule module, @MaybeNull Class<?> classBeingRedefined, ProtectionDomain protectionDomain) Decides if the giventypeDescriptionshould be instrumented with the entailedAgentBuilder.Transformers.- Specified by:
matchesin interfaceAgentBuilder.RawMatcher- Parameters:
typeDescription- A description of the type to be instrumented.classLoader- The class loader of the instrumented type. Might benullif this class loader represents the bootstrap class loader.module- The transformed type's module ornullif the current VM does not support modules.classBeingRedefined- The class being redefined which is only notnullif a retransformation is applied.protectionDomain- The protection domain of the type being transformed.- Returns:
trueif the entailedAgentBuilder.Transformers should be applied for the giventypeDescription.
-