public static class AgentBuilder.Default extends Object implements AgentBuilder
The default implementation of an AgentBuilder
.
By default, Byte Buddy ignores any types loaded by the bootstrap class loader and
any synthetic type. Self-injection and rebasing is enabled. In order to avoid class format changes, set
AgentBuilder.disableBootstrapInjection()
). All types are parsed without their debugging information (AgentBuilder.PoolStrategy.Default.FAST
).
Modifier and Type | Class and Description |
---|---|
protected static interface |
AgentBuilder.Default.BootstrapInjectionStrategy
An injection strategy for injecting classes into the bootstrap class loader.
|
protected class |
AgentBuilder.Default.Delegator<T extends AgentBuilder.Matchable<T>>
An abstract implementation of an agent builder that delegates all invocation to another instance.
|
protected static class |
AgentBuilder.Default.ExecutingTransformer
A
ClassFileTransformer that implements the enclosing agent builder's
configuration. |
protected class |
AgentBuilder.Default.Ignoring
A delegator transformer for further precising what types to ignore.
|
protected static interface |
AgentBuilder.Default.NativeMethodStrategy
A strategy for determining if a native method name prefix should be used when rebasing methods.
|
protected static class |
AgentBuilder.Default.Redefining
An implementation of a default agent builder that allows for refinement of the redefinition strategy.
|
protected static interface |
AgentBuilder.Default.Transformation
A transformation serves as a handler for modifying a class.
|
protected class |
AgentBuilder.Default.Transforming
A helper class that describes a
AgentBuilder.Default after supplying
a AgentBuilder.RawMatcher such that one or several
AgentBuilder.Transformer s can be supplied. |
AgentBuilder.CircularityLock, AgentBuilder.Default, AgentBuilder.DescriptionStrategy, AgentBuilder.FallbackStrategy, AgentBuilder.Identified, AgentBuilder.Ignored, AgentBuilder.InitializationStrategy, AgentBuilder.InstallationListener, AgentBuilder.LambdaInstrumentationStrategy, AgentBuilder.Listener, AgentBuilder.LocationStrategy, AgentBuilder.Matchable<T extends AgentBuilder.Matchable<T>>, AgentBuilder.PoolStrategy, AgentBuilder.RawMatcher, AgentBuilder.RedefinitionListenable, AgentBuilder.RedefinitionStrategy, AgentBuilder.Transformer, AgentBuilder.TypeStrategy
Modifier and Type | Field and Description |
---|---|
protected AgentBuilder.Default.BootstrapInjectionStrategy |
bootstrapInjectionStrategy
The injection strategy for injecting classes into the bootstrap class loader.
|
protected ByteBuddy |
byteBuddy
The
ByteBuddy instance to be used. |
protected AgentBuilder.CircularityLock |
circularityLock
The circularity lock to use.
|
protected AgentBuilder.DescriptionStrategy |
descriptionStrategy
The description strategy for resolving type descriptions for types.
|
protected AgentBuilder.FallbackStrategy |
fallbackStrategy
The fallback strategy to apply.
|
protected AgentBuilder.RawMatcher |
ignoredTypeMatcher
Identifies types that should not be instrumented.
|
protected AgentBuilder.InitializationStrategy |
initializationStrategy
The initialization strategy to use for creating classes.
|
protected AgentBuilder.InstallationListener |
installationListener
The installation listener to notify.
|
protected AgentBuilder.LambdaInstrumentationStrategy |
lambdaInstrumentationStrategy
A strategy to determine of the
LambdaMetafactory should be instrumented to allow for the instrumentation
of classes that represent lambda expressions. |
protected AgentBuilder.Listener |
listener
The listener to notify on transformations.
|
protected AgentBuilder.LocationStrategy |
locationStrategy
The location strategy to use.
|
protected AgentBuilder.Default.NativeMethodStrategy |
nativeMethodStrategy
The native method strategy to use.
|
protected AgentBuilder.PoolStrategy |
poolStrategy
The type locator to use.
|
protected AgentBuilder.RedefinitionStrategy.BatchAllocator |
redefinitionBatchAllocator
The batch allocator for the redefinition strategy to apply.
|
protected AgentBuilder.RedefinitionStrategy.DiscoveryStrategy |
redefinitionDiscoveryStrategy
The discovery strategy for loaded types to be redefined.
|
protected AgentBuilder.RedefinitionStrategy.Listener |
redefinitionListener
The redefinition listener for the redefinition strategy to apply.
|
protected AgentBuilder.RedefinitionStrategy.ResubmissionStrategy |
redefinitionResubmissionStrategy
The resubmission strategy to apply.
|
protected AgentBuilder.RedefinitionStrategy |
redefinitionStrategy
The redefinition strategy to apply.
|
protected AgentBuilder.Default.Transformation |
transformation
The transformation object for handling type transformations.
|
protected AgentBuilder.TypeStrategy |
typeStrategy
The definition handler to use.
|
Modifier and Type | Method and Description |
---|---|
AgentBuilder |
assureReadEdgeFromAndTo(Instrumentation instrumentation,
Class<?>... type)
Assures that all modules of the supplied types are read by the module of any instrumented type and vice versa.
|
AgentBuilder |
assureReadEdgeFromAndTo(Instrumentation instrumentation,
Collection<? extends JavaModule> modules)
Assures that all supplied modules are read by the module of any instrumented type and vice versa.
|
AgentBuilder |
assureReadEdgeFromAndTo(Instrumentation instrumentation,
JavaModule... module)
Assures that all supplied modules are read by the module of any instrumented type and vice versa.
|
AgentBuilder |
assureReadEdgeTo(Instrumentation instrumentation,
Class<?>... type)
Assures that all modules of the supplied types are read by the module of any instrumented type.
|
AgentBuilder |
assureReadEdgeTo(Instrumentation instrumentation,
Collection<? extends JavaModule> modules)
Assures that all supplied modules are read by the module of any instrumented type.
|
AgentBuilder |
assureReadEdgeTo(Instrumentation instrumentation,
JavaModule... module)
Assures that all supplied modules are read by the module of any instrumented type.
|
AgentBuilder |
disableBootstrapInjection()
Disables injection of auxiliary classes into the bootstrap class path.
|
AgentBuilder |
disableClassFormatChanges()
Disables all implicit changes on a class file that Byte Buddy would apply for certain instrumentations.
|
AgentBuilder |
disableNativeMethodPrefix()
Disables the use of a native method prefix for instrumented methods.
|
AgentBuilder |
enableBootstrapInjection(Instrumentation instrumentation,
File folder)
Enables class injection of auxiliary classes into the bootstrap class loader.
|
AgentBuilder |
enableNativeMethodPrefix(String prefix)
Enables the use of the given native method prefix for instrumented methods.
|
AgentBuilder |
enableUnsafeBootstrapInjection()
Enables class injection of auxiliary classes into the bootstrap class loader which relies on
sun.misc.Unsafe . |
AgentBuilder.Ignored |
ignore(AgentBuilder.RawMatcher rawMatcher)
Excludes any type that is matched by the raw matcher provided to this method.
|
AgentBuilder.Ignored |
ignore(ElementMatcher<? super TypeDescription> typeMatcher)
Excludes any type that is matched by the provided matcher from instrumentation and considers types by all
ClassLoader s. |
AgentBuilder.Ignored |
ignore(ElementMatcher<? super TypeDescription> typeMatcher,
ElementMatcher<? super ClassLoader> classLoaderMatcher)
Excludes any type that is matched by the provided matcher and is loaded by a class loader matching the second matcher.
|
AgentBuilder.Ignored |
ignore(ElementMatcher<? super TypeDescription> typeMatcher,
ElementMatcher<? super ClassLoader> classLoaderMatcher,
ElementMatcher<? super JavaModule> moduleMatcher)
Excludes any type that is matched by the provided matcher and is loaded by a class loader matching the second matcher.
|
ResettableClassFileTransformer |
installOn(Instrumentation instrumentation)
Creates and installs a
ClassFileTransformer that implements the configuration of
this agent builder with a given Instrumentation . |
ResettableClassFileTransformer |
installOnByteBuddyAgent()
Creates and installs a
ClassFileTransformer that implements the configuration of
this agent builder with the Byte Buddy-agent which must be installed prior to calling this method. |
ResettableClassFileTransformer |
makeRaw()
Creates a
ClassFileTransformer that implements the configuration of this
agent builder. |
static AgentBuilder |
of(ClassFileVersion classFileVersion,
List<? extends Plugin> plugins)
Creates an
AgentBuilder that realizes the provided build plugins. |
static AgentBuilder |
of(ClassFileVersion classFileVersion,
Plugin... plugin)
Creates an
AgentBuilder that realizes the provided build plugins. |
static AgentBuilder |
of(EntryPoint entryPoint,
ClassFileVersion classFileVersion,
List<? extends Plugin> plugins)
Creates an
AgentBuilder that realizes the provided build plugins. |
static AgentBuilder |
of(EntryPoint entryPoint,
ClassFileVersion classFileVersion,
Plugin... plugin)
Creates an
AgentBuilder that realizes the provided build plugins. |
static AgentBuilder |
of(EntryPoint entryPoint,
List<? extends Plugin> plugins)
Creates an
AgentBuilder that realizes the provided build plugins. |
static AgentBuilder |
of(EntryPoint entryPoint,
Plugin... plugin)
Creates an
AgentBuilder that realizes the provided build plugins. |
static AgentBuilder |
of(List<? extends Plugin> plugins)
Creates an
AgentBuilder that realizes the provided build plugins. |
static AgentBuilder |
of(Plugin... plugin)
Creates an
AgentBuilder that realizes the provided build plugins. |
AgentBuilder.Identified.Narrowable |
type(AgentBuilder.RawMatcher matcher)
Matches a type being loaded in order to apply the supplied
AgentBuilder.Transformer s before loading this type. |
AgentBuilder.Identified.Narrowable |
type(ElementMatcher<? super TypeDescription> typeMatcher)
Matches a type being loaded in order to apply the supplied
AgentBuilder.Transformer s before loading this type. |
AgentBuilder.Identified.Narrowable |
type(ElementMatcher<? super TypeDescription> typeMatcher,
ElementMatcher<? super ClassLoader> classLoaderMatcher)
Matches a type being loaded in order to apply the supplied
AgentBuilder.Transformer s before loading this type. |
AgentBuilder.Identified.Narrowable |
type(ElementMatcher<? super TypeDescription> typeMatcher,
ElementMatcher<? super ClassLoader> classLoaderMatcher,
ElementMatcher<? super JavaModule> moduleMatcher)
Matches a type being loaded in order to apply the supplied
AgentBuilder.Transformer s before loading this type. |
AgentBuilder |
with(AgentBuilder.CircularityLock circularityLock)
Defines a circularity lock that is acquired upon executing code that potentially loads new classes.
|
AgentBuilder |
with(AgentBuilder.DescriptionStrategy descriptionStrategy)
Specifies a strategy to be used for resolving
TypeDescription for any type handled by the created transformer. |
AgentBuilder |
with(AgentBuilder.FallbackStrategy fallbackStrategy)
Specifies a fallback strategy to that this agent builder applies upon installing an agent and during class file transformation.
|
AgentBuilder |
with(AgentBuilder.InitializationStrategy initializationStrategy)
Defines a given initialization strategy to be applied to generated types.
|
AgentBuilder |
with(AgentBuilder.InstallationListener installationListener)
Adds an installation listener that is notified during installation events.
|
AgentBuilder |
with(AgentBuilder.LambdaInstrumentationStrategy lambdaInstrumentationStrategy)
Enables or disables management of the JVM's
LambdaMetafactory which is responsible for creating classes that
implement lambda expressions. |
AgentBuilder |
with(AgentBuilder.Listener listener)
Defines the given
AgentBuilder.Listener to be notified by the created agent. |
AgentBuilder |
with(AgentBuilder.LocationStrategy locationStrategy)
Defines the use of the given location strategy for locating binary data to given class names.
|
AgentBuilder |
with(AgentBuilder.PoolStrategy poolStrategy)
Defines the use of the given type locator for locating a
TypeDescription for an instrumented type. |
AgentBuilder.RedefinitionListenable.WithoutBatchStrategy |
with(AgentBuilder.RedefinitionStrategy redefinitionStrategy)
Specifies a strategy for modifying types that were already loaded prior to the installation of this transformer.
|
AgentBuilder |
with(AgentBuilder.TypeStrategy typeStrategy)
Defines how types should be transformed, e.g.
|
AgentBuilder |
with(ByteBuddy byteBuddy)
Defines the given
ByteBuddy instance to be used by the created agent. |
protected final AgentBuilder.Listener listener
protected final AgentBuilder.CircularityLock circularityLock
protected final AgentBuilder.PoolStrategy poolStrategy
protected final AgentBuilder.TypeStrategy typeStrategy
protected final AgentBuilder.LocationStrategy locationStrategy
protected final AgentBuilder.Default.NativeMethodStrategy nativeMethodStrategy
protected final AgentBuilder.InitializationStrategy initializationStrategy
protected final AgentBuilder.RedefinitionStrategy redefinitionStrategy
protected final AgentBuilder.RedefinitionStrategy.DiscoveryStrategy redefinitionDiscoveryStrategy
protected final AgentBuilder.RedefinitionStrategy.BatchAllocator redefinitionBatchAllocator
protected final AgentBuilder.RedefinitionStrategy.Listener redefinitionListener
protected final AgentBuilder.RedefinitionStrategy.ResubmissionStrategy redefinitionResubmissionStrategy
protected final AgentBuilder.Default.BootstrapInjectionStrategy bootstrapInjectionStrategy
protected final AgentBuilder.LambdaInstrumentationStrategy lambdaInstrumentationStrategy
LambdaMetafactory
should be instrumented to allow for the instrumentation
of classes that represent lambda expressions.protected final AgentBuilder.DescriptionStrategy descriptionStrategy
protected final AgentBuilder.FallbackStrategy fallbackStrategy
protected final AgentBuilder.InstallationListener installationListener
protected final AgentBuilder.RawMatcher ignoredTypeMatcher
protected final AgentBuilder.Default.Transformation transformation
public Default()
ByteBuddy
instance for creating classes.public Default(ByteBuddy byteBuddy)
net.bytebuddy
package and any synthetic type. Self-injection and rebasing is enabled. In order to avoid class format
changes, set AgentBuilder.disableBootstrapInjection()
). All types are parsed without their debugging information
(AgentBuilder.PoolStrategy.Default.FAST
).byteBuddy
- The Byte Buddy instance to be used.protected Default(ByteBuddy byteBuddy, AgentBuilder.Listener listener, AgentBuilder.CircularityLock circularityLock, AgentBuilder.PoolStrategy poolStrategy, AgentBuilder.TypeStrategy typeStrategy, AgentBuilder.LocationStrategy locationStrategy, AgentBuilder.Default.NativeMethodStrategy nativeMethodStrategy, AgentBuilder.InitializationStrategy initializationStrategy, AgentBuilder.RedefinitionStrategy redefinitionStrategy, AgentBuilder.RedefinitionStrategy.DiscoveryStrategy redefinitionDiscoveryStrategy, AgentBuilder.RedefinitionStrategy.BatchAllocator redefinitionBatchAllocator, AgentBuilder.RedefinitionStrategy.Listener redefinitionListener, AgentBuilder.RedefinitionStrategy.ResubmissionStrategy redefinitionResubmissionStrategy, AgentBuilder.Default.BootstrapInjectionStrategy bootstrapInjectionStrategy, AgentBuilder.LambdaInstrumentationStrategy lambdaInstrumentationStrategy, AgentBuilder.DescriptionStrategy descriptionStrategy, AgentBuilder.FallbackStrategy fallbackStrategy, AgentBuilder.InstallationListener installationListener, AgentBuilder.RawMatcher ignoredTypeMatcher, AgentBuilder.Default.Transformation transformation)
byteBuddy
- The Byte Buddy instance to be used.listener
- The listener to notify on transformations.circularityLock
- The circularity lock to use.poolStrategy
- The type locator to use.typeStrategy
- The definition handler to use.locationStrategy
- The location strategy to use.nativeMethodStrategy
- The native method strategy to apply.initializationStrategy
- The initialization strategy to use for transformed types.redefinitionStrategy
- The redefinition strategy to apply.redefinitionDiscoveryStrategy
- The discovery strategy for loaded types to be redefined.redefinitionBatchAllocator
- The batch allocator for the redefinition strategy to apply.redefinitionListener
- The redefinition listener for the redefinition strategy to apply.redefinitionResubmissionStrategy
- The resubmission strategy to apply.bootstrapInjectionStrategy
- The injection strategy for injecting classes into the bootstrap class loader.lambdaInstrumentationStrategy
- A strategy to determine of the LambdaMetafactory
should be instrumented to allow for the
instrumentation of classes that represent lambda expressions.descriptionStrategy
- The description strategy for resolving type descriptions for types.fallbackStrategy
- The fallback strategy to apply.installationListener
- The installation listener to notify.ignoredTypeMatcher
- Identifies types that should not be instrumented.transformation
- The transformation object for handling type transformations.public static AgentBuilder of(Plugin... plugin)
AgentBuilder
that realizes the provided build plugins. As EntryPoint
, EntryPoint.Default#REBASE
is implied.plugin
- The build plugins to apply as a Java agent.public static AgentBuilder of(List<? extends Plugin> plugins)
AgentBuilder
that realizes the provided build plugins. As EntryPoint
, EntryPoint.Default#REBASE
is implied.plugins
- The build plugins to apply as a Java agent.public static AgentBuilder of(EntryPoint entryPoint, Plugin... plugin)
AgentBuilder
that realizes the provided build plugins.entryPoint
- The build entry point to use.plugin
- The build plugins to apply as a Java agent.public static AgentBuilder of(EntryPoint entryPoint, List<? extends Plugin> plugins)
AgentBuilder
that realizes the provided build plugins.entryPoint
- The build entry point to use.plugins
- The build plugins to apply as a Java agent.public static AgentBuilder of(ClassFileVersion classFileVersion, Plugin... plugin)
AgentBuilder
that realizes the provided build plugins. As EntryPoint
, EntryPoint.Default#REBASE
is implied.classFileVersion
- The class file version to use.plugin
- The build plugins to apply as a Java agent.public static AgentBuilder of(ClassFileVersion classFileVersion, List<? extends Plugin> plugins)
AgentBuilder
that realizes the provided build plugins. As EntryPoint
, EntryPoint.Default#REBASE
is implied.classFileVersion
- The class file version to use.plugins
- The build plugins to apply as a Java agent.public static AgentBuilder of(EntryPoint entryPoint, ClassFileVersion classFileVersion, Plugin... plugin)
AgentBuilder
that realizes the provided build plugins.entryPoint
- The build entry point to use.classFileVersion
- The class file version to use.plugin
- The build plugins to apply as a Java agent.public static AgentBuilder of(EntryPoint entryPoint, ClassFileVersion classFileVersion, List<? extends Plugin> plugins)
AgentBuilder
that realizes the provided build plugins.entryPoint
- The build entry point to use.classFileVersion
- The class file version to use.plugins
- The build plugins to apply as a Java agent.public AgentBuilder with(ByteBuddy byteBuddy)
AgentBuilder
ByteBuddy
instance to be used by the created agent.with
in interface AgentBuilder
byteBuddy
- The Byte Buddy instance to be used.byteBuddy
instance.public AgentBuilder with(AgentBuilder.Listener listener)
AgentBuilder
AgentBuilder.Listener
to be notified by the created agent.
The given listener is notified after any other listener that is already registered. If a listener is registered
twice, it is also notified twice.with
in interface AgentBuilder
listener
- The listener to be notified.public AgentBuilder with(AgentBuilder.CircularityLock circularityLock)
AgentBuilder
AgentBuilder.CircularityLock
to avoid that any classes that are required to execute an agent
causes a ClassCircularityError
.with
in interface AgentBuilder
circularityLock
- The circularity lock to use.public AgentBuilder with(AgentBuilder.TypeStrategy typeStrategy)
AgentBuilder
with
in interface AgentBuilder
typeStrategy
- The type strategy to use.public AgentBuilder with(AgentBuilder.PoolStrategy poolStrategy)
AgentBuilder
TypeDescription
for an instrumented type.with
in interface AgentBuilder
poolStrategy
- The type locator to use.public AgentBuilder with(AgentBuilder.LocationStrategy locationStrategy)
AgentBuilder
with
in interface AgentBuilder
locationStrategy
- The location strategy to use.public AgentBuilder enableNativeMethodPrefix(String prefix)
AgentBuilder
Instrumentation
.enableNativeMethodPrefix
in interface AgentBuilder
prefix
- The prefix to be used.public AgentBuilder disableNativeMethodPrefix()
AgentBuilder
disableNativeMethodPrefix
in interface AgentBuilder
public AgentBuilder.RedefinitionListenable.WithoutBatchStrategy with(AgentBuilder.RedefinitionStrategy redefinitionStrategy)
AgentBuilder
Specifies a strategy for modifying types that were already loaded prior to the installation of this transformer.
Note: Defining a redefinition strategy resets any refinements of a previously set redefinition strategy.
Important: Most JVMs do not support changes of a class's structure after a class was already
loaded. Therefore, it is typically required that this class file transformer was built while enabling
AgentBuilder.disableClassFormatChanges()
.
with
in interface AgentBuilder
redefinitionStrategy
- The redefinition strategy to apply.public AgentBuilder with(AgentBuilder.InitializationStrategy initializationStrategy)
AgentBuilder
with
in interface AgentBuilder
initializationStrategy
- The initialization strategy to use.public AgentBuilder with(AgentBuilder.LambdaInstrumentationStrategy lambdaInstrumentationStrategy)
AgentBuilder
Enables or disables management of the JVM's LambdaMetafactory
which is responsible for creating classes that
implement lambda expressions. Without this feature enabled, classes that are represented by lambda expressions are
not instrumented by the JVM such that Java agents have no effect on them when a lambda expression's class is loaded
for the first time.
When activating this feature, Byte Buddy instruments the LambdaMetafactory
and takes over the responsibility
of creating classes that represent lambda expressions. In doing so, Byte Buddy has the opportunity to apply the built
class file transformer. If the current VM does not support lambda expressions, activating this feature has no effect.
Important: If this feature is active, it is important to release the built class file transformer when
deactivating it. Normally, it is sufficient to call Instrumentation.removeTransformer(ClassFileTransformer)
.
When this feature is enabled, it is however also required to invoke
AgentBuilder.LambdaInstrumentationStrategy.release(ClassFileTransformer, Instrumentation)
. Otherwise, the executing VMs class
loader retains a reference to the class file transformer what can cause a memory leak.
with
in interface AgentBuilder
lambdaInstrumentationStrategy
- true
if this feature should be enabled.public AgentBuilder with(AgentBuilder.DescriptionStrategy descriptionStrategy)
AgentBuilder
TypeDescription
for any type handled by the created transformer.with
in interface AgentBuilder
descriptionStrategy
- The description strategy to use.public AgentBuilder with(AgentBuilder.FallbackStrategy fallbackStrategy)
AgentBuilder
with
in interface AgentBuilder
fallbackStrategy
- The fallback strategy to be used.public AgentBuilder with(AgentBuilder.InstallationListener installationListener)
AgentBuilder
ResettableClassFileTransformer
's reset
methods.with
in interface AgentBuilder
installationListener
- The installation listener to register.public AgentBuilder enableBootstrapInjection(Instrumentation instrumentation, File folder)
AgentBuilder
enableBootstrapInjection
in interface AgentBuilder
instrumentation
- The instrumentation instance that is used for appending jar files to the
bootstrap class path.folder
- The folder in which jar files of the injected classes are to be stored.public AgentBuilder enableUnsafeBootstrapInjection()
AgentBuilder
sun.misc.Unsafe
.enableUnsafeBootstrapInjection
in interface AgentBuilder
public AgentBuilder disableBootstrapInjection()
AgentBuilder
disableBootstrapInjection
in interface AgentBuilder
public AgentBuilder disableClassFormatChanges()
AgentBuilder
Disables all implicit changes on a class file that Byte Buddy would apply for certain instrumentations. When using this option, it is no longer possible to rebase a method, i.e. intercepted methods are fully replaced. Furthermore, it is no longer possible to implicitly apply loaded type initializers for explicitly initializing the generated type.
This is equivalent to setting AgentBuilder.InitializationStrategy.NoOp
and AgentBuilder.TypeStrategy.Default.REDEFINE_FROZEN
as well as configuring the underlying ByteBuddy
instance to use a Implementation.Context.Disabled
.
Using this strategy also configures Byte Buddy to create frozen instrumented types and discards any explicit configuration.
disableClassFormatChanges
in interface AgentBuilder
public AgentBuilder assureReadEdgeTo(Instrumentation instrumentation, Class<?>... type)
AgentBuilder
assureReadEdgeTo
in interface AgentBuilder
instrumentation
- The instrumentation instance that is used for adding a module read-dependency.type
- The types for which to assure their module-visibility from any instrumented class.AgentBuilder.Listener.ModuleReadEdgeCompleting
public AgentBuilder assureReadEdgeTo(Instrumentation instrumentation, JavaModule... module)
AgentBuilder
assureReadEdgeTo
in interface AgentBuilder
instrumentation
- The instrumentation instance that is used for adding a module read-dependency.module
- The modules for which to assure their module-visibility from any instrumented class.AgentBuilder.Listener.ModuleReadEdgeCompleting
public AgentBuilder assureReadEdgeTo(Instrumentation instrumentation, Collection<? extends JavaModule> modules)
AgentBuilder
assureReadEdgeTo
in interface AgentBuilder
instrumentation
- The instrumentation instance that is used for adding a module read-dependency.modules
- The modules for which to assure their module-visibility from any instrumented class.AgentBuilder.Listener.ModuleReadEdgeCompleting
public AgentBuilder assureReadEdgeFromAndTo(Instrumentation instrumentation, Class<?>... type)
AgentBuilder
assureReadEdgeFromAndTo
in interface AgentBuilder
instrumentation
- The instrumentation instance that is used for adding a module read-dependency.type
- The types for which to assure their module-visibility from and to any instrumented class.AgentBuilder.Listener.ModuleReadEdgeCompleting
public AgentBuilder assureReadEdgeFromAndTo(Instrumentation instrumentation, JavaModule... module)
AgentBuilder
assureReadEdgeFromAndTo
in interface AgentBuilder
instrumentation
- The instrumentation instance that is used for adding a module read-dependency.module
- The modules for which to assure their module-visibility from and to any instrumented class.AgentBuilder.Listener.ModuleReadEdgeCompleting
public AgentBuilder assureReadEdgeFromAndTo(Instrumentation instrumentation, Collection<? extends JavaModule> modules)
AgentBuilder
assureReadEdgeFromAndTo
in interface AgentBuilder
instrumentation
- The instrumentation instance that is used for adding a module read-dependency.modules
- The modules for which to assure their module-visibility from and to any instrumented class.AgentBuilder.Listener.ModuleReadEdgeCompleting
public AgentBuilder.Identified.Narrowable type(AgentBuilder.RawMatcher matcher)
AgentBuilder
Matches a type being loaded in order to apply the supplied AgentBuilder.Transformer
s before loading this type.
If several matchers positively match a type only the latest registered matcher is considered for transformation.
If this matcher is chained with additional subsequent matchers, this matcher is always executed first whereas the following matchers are executed in the order of their execution. If any matcher indicates that a type is to be matched, none of the following matchers is still queried.
Note: When applying a matcher, regard the performance implications by AgentBuilder.ignore(ElementMatcher)
. The former
matcher is applied first such that it makes sense to ignore name spaces that are irrelevant to instrumentation. If possible, it
is also recommended, to exclude class loaders such as for example the bootstrap class loader.
type
in interface AgentBuilder
matcher
- A matcher that decides if the entailed AgentBuilder.Transformer
s should be
applied for a type that is being loaded.AgentBuilder.Transformer
s to be applied when the given matcher
indicates a match.public AgentBuilder.Identified.Narrowable type(ElementMatcher<? super TypeDescription> typeMatcher)
AgentBuilder
Matches a type being loaded in order to apply the supplied AgentBuilder.Transformer
s before loading this type.
If several matchers positively match a type only the latest registered matcher is considered for transformation.
If this matcher is chained with additional subsequent matchers, this matcher is always executed first whereas the following matchers are
executed in the order of their execution. If any matcher indicates that a type is to be matched, none of the following matchers is still queried.
This behavior can be changed by AgentBuilder.Identified.Extendable.asDecorator()
where subsequent type matchers are also applied.
Note: When applying a matcher, regard the performance implications by AgentBuilder.ignore(ElementMatcher)
. The former
matcher is applied first such that it makes sense to ignore name spaces that are irrelevant to instrumentation. If possible, it is
also recommended, to exclude class loaders such as for example the bootstrap class loader by using
AgentBuilder.type(ElementMatcher, ElementMatcher)
instead.
type
in interface AgentBuilder
typeMatcher
- An ElementMatcher
that is applied on the type being loaded that
decides if the entailed AgentBuilder.Transformer
s should
be applied for that type.AgentBuilder.Transformer
s to be applied when the given typeMatcher
indicates a match.public AgentBuilder.Identified.Narrowable type(ElementMatcher<? super TypeDescription> typeMatcher, ElementMatcher<? super ClassLoader> classLoaderMatcher)
AgentBuilder
Matches a type being loaded in order to apply the supplied AgentBuilder.Transformer
s before loading this type.
If several matchers positively match a type only the latest registered matcher is considered for transformation.
If this matcher is chained with additional subsequent matchers, this matcher is always executed first whereas the following matchers are
executed in the order of their execution. If any matcher indicates that a type is to be matched, none of the following matchers is still queried.
This behavior can be changed by AgentBuilder.Identified.Extendable.asDecorator()
where subsequent type matchers are also applied.
Note: When applying a matcher, regard the performance implications by AgentBuilder.ignore(ElementMatcher)
. The former
matcher is applied first such that it makes sense to ignore name spaces that are irrelevant to instrumentation. If possible, it
is also recommended, to exclude class loaders such as for example the bootstrap class loader.
type
in interface AgentBuilder
typeMatcher
- An ElementMatcher
that is applied on the type being
loaded that decides if the entailed
AgentBuilder.Transformer
s should be applied for
that type.classLoaderMatcher
- An ElementMatcher
that is applied to the
ClassLoader
that is loading the type being loaded. This matcher
is always applied first where the type matcher is not applied in case that this
matcher does not indicate a match.AgentBuilder.Transformer
s to be applied when both the given
typeMatcher
and classLoaderMatcher
indicate a match.public AgentBuilder.Identified.Narrowable type(ElementMatcher<? super TypeDescription> typeMatcher, ElementMatcher<? super ClassLoader> classLoaderMatcher, ElementMatcher<? super JavaModule> moduleMatcher)
AgentBuilder
Matches a type being loaded in order to apply the supplied AgentBuilder.Transformer
s before loading this type.
If several matchers positively match a type only the latest registered matcher is considered for transformation.
If this matcher is chained with additional subsequent matchers, this matcher is always executed first whereas the following matchers are
executed in the order of their execution. If any matcher indicates that a type is to be matched, none of the following matchers is still queried.
This behavior can be changed by AgentBuilder.Identified.Extendable.asDecorator()
where subsequent type matchers are also applied.
Note: When applying a matcher, regard the performance implications by AgentBuilder.ignore(ElementMatcher)
. The former
matcher is applied first such that it makes sense to ignore name spaces that are irrelevant to instrumentation. If possible, it
is also recommended, to exclude class loaders such as for example the bootstrap class loader.
type
in interface AgentBuilder
typeMatcher
- An ElementMatcher
that is applied on the type being
loaded that decides if the entailed
AgentBuilder.Transformer
s should be applied for
that type.classLoaderMatcher
- An ElementMatcher
that is applied to the
ClassLoader
that is loading the type being loaded. This matcher
is always applied second where the type matcher is not applied in case that this
matcher does not indicate a match.moduleMatcher
- An ElementMatcher
that is applied to the JavaModule
of the type being loaded. This matcher is always applied first where the class loader and
type matchers are not applied in case that this matcher does not indicate a match. On a JVM
that does not support the Java modules system, this matcher is not applied.AgentBuilder.Transformer
s to be applied when both the given
typeMatcher
and classLoaderMatcher
indicate a match.public AgentBuilder.Ignored ignore(ElementMatcher<? super TypeDescription> typeMatcher)
AgentBuilder
Excludes any type that is matched by the provided matcher from instrumentation and considers types by all ClassLoader
s.
By default, Byte Buddy does not instrument synthetic types or types that are loaded by the bootstrap class loader.
When ignoring a type, any subsequently chained matcher is applied after this matcher in the order of their registration. Also, if any matcher indicates that a type is to be ignored, none of the following chained matchers is executed.
Note: For performance reasons, it is recommended to always include a matcher that excludes as many namespaces as possible. Byte Buddy can determine a type's name without parsing its class file and can therefore discard such types with minimal overhead. When a different property of a type - such as for example its modifiers or its annotations is accessed - Byte Buddy parses the class file lazily in order to allow for such a matching. Therefore, any exclusion of a name should always be done as a first step and even if it does not influence the selection of what types are matched. Without changing this property, the class file of every type is being parsed!
Warning: If a type is loaded during the instrumentation of the same type, this causes the original call site that loads the type
to remain unbound, causing a LinkageError
. It is therefore important to not instrument types that may be loaded during the application
of a AgentBuilder.Transformer
. For this reason, it is not recommended to instrument classes of the bootstrap class loader that Byte Buddy might
require for instrumenting a class or to instrument any of Byte Buddy's classes. If such instrumentation is desired, it is important to
assert for each class that they are not loaded during instrumentation.
ignore
in interface AgentBuilder
typeMatcher
- A matcher that identifies types that should not be instrumented.public AgentBuilder.Ignored ignore(ElementMatcher<? super TypeDescription> typeMatcher, ElementMatcher<? super ClassLoader> classLoaderMatcher)
AgentBuilder
Excludes any type that is matched by the provided matcher and is loaded by a class loader matching the second matcher.
By default, Byte Buddy does not instrument synthetic types, types within a net.bytebuddy.*
package or types that
are loaded by the bootstrap class loader.
When ignoring a type, any subsequently chained matcher is applied after this matcher in the order of their registration. Also, if any matcher indicates that a type is to be ignored, none of the following chained matchers is executed.
Note: For performance reasons, it is recommended to always include a matcher that excludes as many namespaces as possible. Byte Buddy can determine a type's name without parsing its class file and can therefore discard such types with minimal overhead. When a different property of a type - such as for example its modifiers or its annotations is accessed - Byte Buddy parses the class file lazily in order to allow for such a matching. Therefore, any exclusion of a name should always be done as a first step and even if it does not influence the selection of what types are matched. Without changing this property, the class file of every type is being parsed!
Warning: If a type is loaded during the instrumentation of the same type, this causes the original call site that loads the type
to remain unbound, causing a LinkageError
. It is therefore important to not instrument types that may be loaded during the application
of a AgentBuilder.Transformer
. For this reason, it is not recommended to instrument classes of the bootstrap class loader that Byte Buddy might
require for instrumenting a class or to instrument any of Byte Buddy's classes. If such instrumentation is desired, it is important to
assert for each class that they are not loaded during instrumentation.
ignore
in interface AgentBuilder
typeMatcher
- A matcher that identifies types that should not be instrumented.classLoaderMatcher
- A matcher that identifies a class loader that identifies classes that should not be instrumented.public AgentBuilder.Ignored ignore(ElementMatcher<? super TypeDescription> typeMatcher, ElementMatcher<? super ClassLoader> classLoaderMatcher, ElementMatcher<? super JavaModule> moduleMatcher)
AgentBuilder
Excludes any type that is matched by the provided matcher and is loaded by a class loader matching the second matcher.
By default, Byte Buddy does not instrument synthetic types, types within a net.bytebuddy.*
package or types that
are loaded by the bootstrap class loader.
When ignoring a type, any subsequently chained matcher is applied after this matcher in the order of their registration. Also, if any matcher indicates that a type is to be ignored, none of the following chained matchers is executed.
Note: For performance reasons, it is recommended to always include a matcher that excludes as many namespaces as possible. Byte Buddy can determine a type's name without parsing its class file and can therefore discard such types with minimal overhead. When a different property of a type - such as for example its modifiers or its annotations is accessed - Byte Buddy parses the class file lazily in order to allow for such a matching. Therefore, any exclusion of a name should always be done as a first step and even if it does not influence the selection of what types are matched. Without changing this property, the class file of every type is being parsed!
Warning: If a type is loaded during the instrumentation of the same type, this causes the original call site that loads the type
to remain unbound, causing a LinkageError
. It is therefore important to not instrument types that may be loaded during the application
of a AgentBuilder.Transformer
. For this reason, it is not recommended to instrument classes of the bootstrap class loader that Byte Buddy might
require for instrumenting a class or to instrument any of Byte Buddy's classes. If such instrumentation is desired, it is important to
assert for each class that they are not loaded during instrumentation.
ignore
in interface AgentBuilder
typeMatcher
- A matcher that identifies types that should not be instrumented.classLoaderMatcher
- A matcher that identifies a class loader that identifies classes that should not be instrumented.moduleMatcher
- A matcher that identifies a module that identifies classes that should not be instrumented. On a JVM
that does not support the Java modules system, this matcher is not applied.public AgentBuilder.Ignored ignore(AgentBuilder.RawMatcher rawMatcher)
AgentBuilder
Excludes any type that is matched by the raw matcher provided to this method. By default, Byte Buddy does not
instrument synthetic types, types within a net.bytebuddy.*
package or types that are loaded by the bootstrap class loader.
When ignoring a type, any subsequently chained matcher is applied after this matcher in the order of their registration. Also, if any matcher indicates that a type is to be ignored, none of the following chained matchers is executed.
Note: For performance reasons, it is recommended to always include a matcher that excludes as many namespaces as possible. Byte Buddy can determine a type's name without parsing its class file and can therefore discard such types with minimal overhead. When a different property of a type - such as for example its modifiers or its annotations is accessed - Byte Buddy parses the class file lazily in order to allow for such a matching. Therefore, any exclusion of a name should always be done as a first step and even if it does not influence the selection of what types are matched. Without changing this property, the class file of every type is being parsed!
Warning: If a type is loaded during the instrumentation of the same type, this causes the original call site that loads the type
to remain unbound, causing a LinkageError
. It is therefore important to not instrument types that may be loaded during the application
of a AgentBuilder.Transformer
. For this reason, it is not recommended to instrument classes of the bootstrap class loader that Byte Buddy might
require for instrumenting a class or to instrument any of Byte Buddy's classes. If such instrumentation is desired, it is important to
assert for each class that they are not loaded during instrumentation.
ignore
in interface AgentBuilder
rawMatcher
- A raw matcher that identifies types that should not be instrumented.public ResettableClassFileTransformer makeRaw()
AgentBuilder
ClassFileTransformer
that implements the configuration of this
agent builder. When using a raw class file transformer, the AgentBuilder.InstallationListener
callbacks are
not invoked and the set AgentBuilder.RedefinitionStrategy
is not applied onto currently loaded classes.makeRaw
in interface AgentBuilder
public ResettableClassFileTransformer installOn(Instrumentation instrumentation)
AgentBuilder
Creates and installs a ClassFileTransformer
that implements the configuration of
this agent builder with a given Instrumentation
. If retransformation is enabled,
the installation also causes all loaded types to be retransformed.
In order to assure the correct handling of the AgentBuilder.InstallationListener
, an uninstallation should be applied
via the ResettableClassFileTransformer
's reset
methods.
installOn
in interface AgentBuilder
instrumentation
- The instrumentation on which this agent builder's configuration is to be installed.public ResettableClassFileTransformer installOnByteBuddyAgent()
AgentBuilder
ClassFileTransformer
that implements the configuration of
this agent builder with the Byte Buddy-agent which must be installed prior to calling this method.installOnByteBuddyAgent
in interface AgentBuilder
AgentBuilder.installOn(Instrumentation)
Copyright © 2014–2018. All rights reserved.