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.RawMatcher
that only matches the suppliedTypeDescription
against a supplied matcher.ForElementMatchers
(ElementMatcher<? super TypeDescription> typeMatcher, ElementMatcher<? super ClassLoader> classLoaderMatcher) Creates a newAgentBuilder.RawMatcher
that only matches the suppliedTypeDescription
and itsClassLoader
against 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.RawMatcher
that only matches the suppliedTypeDescription
, itsClassLoader
and module against element suitable matchers. -
Method Summary
Modifier and TypeMethodDescriptionboolean
matches
(TypeDescription typeDescription, ClassLoader classLoader, JavaModule module, Class<?> classBeingRedefined, ProtectionDomain protectionDomain) Decides if the giventypeDescription
should be instrumented with the entailedAgentBuilder.Transformer
s.
-
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.RawMatcher
that only matches the suppliedTypeDescription
against 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.RawMatcher
that only matches the suppliedTypeDescription
and itsClassLoader
against 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.RawMatcher
that only matches the suppliedTypeDescription
, itsClassLoader
and 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 giventypeDescription
should be instrumented with the entailedAgentBuilder.Transformer
s.- Specified by:
matches
in interfaceAgentBuilder.RawMatcher
- Parameters:
typeDescription
- A description of the type to be instrumented.classLoader
- The class loader of the instrumented type. Might benull
if this class loader represents the bootstrap class loader.module
- The transformed type's module ornull
if the current VM does not support modules.classBeingRedefined
- The class being redefined which is only notnull
if a retransformation is applied.protectionDomain
- The protection domain of the type being transformed.- Returns:
true
if the entailedAgentBuilder.Transformer
s should be applied for the giventypeDescription
.
-