Class AgentBuilder.Default
- All Implemented Interfaces:
AgentBuilder
- Direct Known Subclasses:
AgentBuilder.Default.Redefining
- Enclosing interface:
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.disableClassFormatChanges()
. All types are parsed without their debugging information
(AgentBuilder.PoolStrategy.Default.FAST
).
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionprotected static class
An abstract implementation of an agent builder that delegates all invocation to another instance.protected static interface
A dispatcher for interacting with the instrumentation API.protected static class
AClassFileTransformer
that implements the enclosing agent builder's configuration.protected class
A delegator transformer for further precising what types to ignore.protected static interface
A strategy for determining if a native method name prefix should be used when rebasing methods.protected static class
An implementation of a default agent builder that allows for refinement of the redefinition strategy.protected static class
A transformation to apply.protected class
A helper class that describes aAgentBuilder.Default
after supplying aAgentBuilder.RawMatcher
such that one or severalAgentBuilder.Transformer
s can be supplied.protected static interface
A strategy to warm up aClassFileTransformer
before using it to eagerly load classes and to avoid circularity errors when classes are loaded during actual transformation for the first time.Nested classes/interfaces inherited from interface net.bytebuddy.agent.builder.AgentBuilder
AgentBuilder.CircularityLock, AgentBuilder.ClassFileBufferStrategy, AgentBuilder.Default, AgentBuilder.DescriptionStrategy, AgentBuilder.FallbackStrategy, AgentBuilder.Identified, AgentBuilder.Ignored, AgentBuilder.InitializationStrategy, AgentBuilder.InjectionStrategy, AgentBuilder.InstallationListener, AgentBuilder.LambdaInstrumentationStrategy, AgentBuilder.Listener, AgentBuilder.LocationStrategy, AgentBuilder.Matchable<T extends AgentBuilder.Matchable<T>>, AgentBuilder.PatchMode, AgentBuilder.PoolStrategy, AgentBuilder.RawMatcher, AgentBuilder.RedefinitionListenable, AgentBuilder.RedefinitionStrategy, AgentBuilder.Transformer, AgentBuilder.TransformerDecorator, AgentBuilder.TypeStrategy
-
Field Summary
FieldsModifier and TypeFieldDescriptionprotected final ByteBuddy
TheByteBuddy
instance to be used.protected final AgentBuilder.CircularityLock
The circularity lock to use.protected final AgentBuilder.ClassFileBufferStrategy
The class file buffer strategy to use.protected final ClassFileLocator
A class file locator to be used for additional lookup of globally available types.private static final AgentBuilder.CircularityLock
The default circularity lock that assures that no agent created by any agent builder within this class loader causes a class loading circularity.protected final AgentBuilder.DescriptionStrategy
The description strategy for resolving type descriptions for types.private static final AgentBuilder.Default.Dispatcher
A dipatcher to use for interacting with the instrumentation API.protected final AgentBuilder.FallbackStrategy
The fallback strategy to apply.protected final AgentBuilder.RawMatcher
Identifies types that should not be instrumented.protected final AgentBuilder.InitializationStrategy
The initialization strategy to use for creating classes.protected final AgentBuilder.InjectionStrategy
The injection strategy for injecting classes into a class loader.protected final AgentBuilder.InstallationListener
The installation listener to notify.private static final String
The name of the getter fornet.bytebuddy.agent.Installer
to read theInstrumentation
.private static final String
The name of the Byte Buddynet.bytebuddy.agent.Installer
class.protected final AgentBuilder.LambdaInstrumentationStrategy
A strategy to determine of theLambdaMetafactory
should be instrumented to allow for the instrumentation of classes that represent lambda expressions.protected final AgentBuilder.Listener
The listener to notify on transformations.protected final AgentBuilder.LocationStrategy
The location strategy to use.protected final AgentBuilder.Default.NativeMethodStrategy
The native method strategy to use.private static final byte[]
The value that is to be returned from aClassFileTransformer
to indicate that no class file transformation is to be applied.private static final Class
<?> A type-safe constant to express that a class is not already loaded when applying a class file transformer.protected final AgentBuilder.PoolStrategy
The pool strategy to use.protected final AgentBuilder.RedefinitionStrategy.BatchAllocator
The batch allocator for the redefinition strategy to apply.protected final AgentBuilder.RedefinitionStrategy.DiscoveryStrategy
The discovery strategy for loaded types to be redefined.protected final AgentBuilder.RedefinitionStrategy.Listener
The redefinition listener for the redefinition strategy to apply.protected final AgentBuilder.RedefinitionStrategy.ResubmissionStrategy
The resubmission strategy to apply.protected final AgentBuilder.RedefinitionStrategy
The redefinition strategy to apply.protected final List
<AgentBuilder.Default.Transformation> The transformation object for handling type transformations.protected final AgentBuilder.TransformerDecorator
A decorator to wrap the created class file transformer.protected final AgentBuilder.TypeStrategy
The definition handler to use.protected final AgentBuilder.Default.WarmupStrategy
The warmup strategy to use. -
Constructor Summary
ConstructorsModifierConstructorDescriptionDefault()
Creates a new default agent builder that uses a defaultByteBuddy
instance for creating classes.Creates a new agent builder with default settings.protected
Default
(ByteBuddy byteBuddy, AgentBuilder.Listener listener, AgentBuilder.CircularityLock circularityLock, AgentBuilder.PoolStrategy poolStrategy, AgentBuilder.TypeStrategy typeStrategy, AgentBuilder.LocationStrategy locationStrategy, ClassFileLocator classFileLocator, AgentBuilder.Default.NativeMethodStrategy nativeMethodStrategy, AgentBuilder.Default.WarmupStrategy warmupStrategy, AgentBuilder.TransformerDecorator transformerDecorator, AgentBuilder.InitializationStrategy initializationStrategy, AgentBuilder.RedefinitionStrategy redefinitionStrategy, AgentBuilder.RedefinitionStrategy.DiscoveryStrategy redefinitionDiscoveryStrategy, AgentBuilder.RedefinitionStrategy.BatchAllocator redefinitionBatchAllocator, AgentBuilder.RedefinitionStrategy.Listener redefinitionListener, AgentBuilder.RedefinitionStrategy.ResubmissionStrategy redefinitionResubmissionStrategy, AgentBuilder.InjectionStrategy injectionStrategy, AgentBuilder.LambdaInstrumentationStrategy lambdaInstrumentationStrategy, AgentBuilder.DescriptionStrategy descriptionStrategy, AgentBuilder.FallbackStrategy fallbackStrategy, AgentBuilder.ClassFileBufferStrategy classFileBufferStrategy, AgentBuilder.InstallationListener installationListener, AgentBuilder.RawMatcher ignoreMatcher, List<AgentBuilder.Default.Transformation> transformations) Creates a new default agent builder. -
Method Summary
Modifier and TypeMethodDescriptionassureReadEdgeFromAndTo
(Instrumentation instrumentation, Class<?>... type) Assures that all modules of the supplied types are read by the module of any instrumented type and vice versa.assureReadEdgeFromAndTo
(Instrumentation instrumentation, Collection<? extends JavaModule> modules) Assures that all supplied modules are read by the module of any instrumented type and vice versa.assureReadEdgeFromAndTo
(Instrumentation instrumentation, JavaModule... module) Assures that all supplied modules are read by the module of any instrumented type and vice versa.assureReadEdgeTo
(Instrumentation instrumentation, Class<?>... type) Assures that all modules of the supplied types are read by the module of any instrumented type.assureReadEdgeTo
(Instrumentation instrumentation, Collection<? extends JavaModule> modules) Assures that all supplied modules are read by the module of any instrumented type.assureReadEdgeTo
(Instrumentation instrumentation, JavaModule... module) Assures that all supplied modules are read by the module of any instrumented type.Disables all implicit changes on a class file that Byte Buddy would apply for certain instrumentations.Disables the use of a native method prefix for instrumented methods.private ResettableClassFileTransformer
doInstall
(Instrumentation instrumentation, AgentBuilder.RawMatcher matcher, AgentBuilder.PatchMode.Handler handler) Installs the class file transformer.private static <T> T
doPrivileged
(PrivilegedAction<T> action) A proxy forjava.security.AccessController#doPrivileged
that is activated if available.enableNativeMethodPrefix
(String prefix) Enables the use of the given native method prefix for instrumented methods.ignore
(AgentBuilder.RawMatcher rawMatcher) Excludes any type that is matched by the raw matcher provided to this method.ignore
(ElementMatcher<? super TypeDescription> typeMatcher) Excludes any type that is matched by the provided matcher from instrumentation and considers types by allClassLoader
s.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.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.installOn
(Instrumentation instrumentation) Creates and installs aResettableClassFileTransformer
that implements the configuration of this agent builder with a givenInstrumentation
.Creates and installs aResettableClassFileTransformer
that implements the configuration of this agent builder with the Byte Buddy-agent which must be installed prior to calling this method.makeRaw()
Creates aResettableClassFileTransformer
that implements the configuration of this agent builder.private ResettableClassFileTransformer
makeRaw
(AgentBuilder.Listener listener, AgentBuilder.InstallationListener installationListener, AgentBuilder.RedefinitionStrategy.ResubmissionEnforcer resubmissionEnforcer) Creates a new class file transformer with a given listener.static AgentBuilder
Creates anAgentBuilder
that realizes the provided build plugins.static AgentBuilder
of
(EntryPoint entryPoint, List<? extends Plugin> plugins) Creates anAgentBuilder
that realizes the provided build plugins.static AgentBuilder
of
(EntryPoint entryPoint, Plugin... plugin) Creates anAgentBuilder
that realizes the provided build plugins.static AgentBuilder
of
(EntryPoint entryPoint, ClassFileVersion classFileVersion, List<? extends Plugin> plugins) Creates anAgentBuilder
that realizes the provided build plugins.static AgentBuilder
of
(EntryPoint entryPoint, ClassFileVersion classFileVersion, Plugin... plugin) Creates anAgentBuilder
that realizes the provided build plugins.static AgentBuilder
Creates anAgentBuilder
that realizes the provided build plugins.static AgentBuilder
of
(ClassFileVersion classFileVersion, List<? extends Plugin> plugins) Creates anAgentBuilder
that realizes the provided build plugins.static AgentBuilder
of
(ClassFileVersion classFileVersion, Plugin... plugin) Creates anAgentBuilder
that realizes the provided build plugins.patchOn
(Instrumentation instrumentation, ResettableClassFileTransformer classFileTransformer) Creates and installs aResettableClassFileTransformer
that implements the configuration of this agent builder with a givenInstrumentation
.patchOn
(Instrumentation instrumentation, ResettableClassFileTransformer classFileTransformer, AgentBuilder.PatchMode patchMode) Creates and installs aResettableClassFileTransformer
that implements the configuration of this agent builder with a givenInstrumentation
.patchOnByteBuddyAgent
(ResettableClassFileTransformer classFileTransformer) Creates and installs aResettableClassFileTransformer
that implements the configuration of this agent builder with the Byte Buddy-agent which must be installed prior to calling this method.patchOnByteBuddyAgent
(ResettableClassFileTransformer classFileTransformer, AgentBuilder.PatchMode patchMode) Creates and installs aResettableClassFileTransformer
that implements the configuration of this agent builder with the Byte Buddy-agent which must be installed prior to calling this method.private static Instrumentation
Resolves the instrumentation provided bynet.bytebuddy.agent.Installer
.type
(AgentBuilder.RawMatcher matcher) Matches a type being loaded in order to apply the suppliedAgentBuilder.Transformer
s before loading this type.type
(ElementMatcher<? super TypeDescription> typeMatcher) Matches a type being loaded in order to apply the suppliedAgentBuilder.Transformer
s before loading this type.type
(ElementMatcher<? super TypeDescription> typeMatcher, ElementMatcher<? super ClassLoader> classLoaderMatcher) Matches a type being loaded in order to apply the suppliedAgentBuilder.Transformer
s before loading this type.type
(ElementMatcher<? super TypeDescription> typeMatcher, ElementMatcher<? super ClassLoader> classLoaderMatcher, ElementMatcher<? super JavaModule> moduleMatcher) Matches a type being loaded in order to apply the suppliedAgentBuilder.Transformer
s before loading this type.Warms up the generatedClassFileTransformer
to trigger class loading of classes used by the transformer prior to its actual use.warmUp
(Collection<Class<?>> types) Warms up the generatedClassFileTransformer
to trigger class loading of classes used by the transformer prior to its actual use.with
(AgentBuilder.CircularityLock circularityLock) Defines a circularity lock that is acquired upon executing code that potentially loads new classes.with
(AgentBuilder.ClassFileBufferStrategy classFileBufferStrategy) Specifies a class file buffer strategy that determines the use of the buffer supplied to a class file transformer.with
(AgentBuilder.DescriptionStrategy descriptionStrategy) Specifies a strategy to be used for resolvingTypeDescription
for any type handled by the created transformer.with
(AgentBuilder.FallbackStrategy fallbackStrategy) Specifies a fallback strategy to that this agent builder applies upon installing an agent and during class file transformation.with
(AgentBuilder.InitializationStrategy initializationStrategy) Defines a given initialization strategy to be applied to generated types.with
(AgentBuilder.InjectionStrategy injectionStrategy) Defines a strategy for injecting auxiliary types into the target class loader.with
(AgentBuilder.InstallationListener installationListener) Adds an installation listener that is notified during installation events.with
(AgentBuilder.LambdaInstrumentationStrategy lambdaInstrumentationStrategy) Enables or disables management of the JVM'sLambdaMetafactory
which is responsible for creating classes that implement lambda expressions.with
(AgentBuilder.Listener listener) Defines the givenAgentBuilder.Listener
to be notified by the created agent.with
(AgentBuilder.LocationStrategy locationStrategy) Defines the use of the given location strategy for locating binary data to given class names.with
(AgentBuilder.PoolStrategy poolStrategy) Defines the use of the given type locator for locating aTypeDescription
for an instrumented type.with
(AgentBuilder.RedefinitionStrategy redefinitionStrategy) Specifies a strategy for modifying types that were already loaded prior to the installation of this transformer.with
(AgentBuilder.TransformerDecorator transformerDecorator) Adds a decorator for the created class file transformer.with
(AgentBuilder.TypeStrategy typeStrategy) Defines how types should be transformed, e.g.Defines the givenByteBuddy
instance to be used by the created agent.with
(ClassFileLocator classFileLocator) Registers an additional class file locator for types that are globally available but cannot be located otherwise.
-
Field Details
-
INSTALLER_TYPE
The name of the Byte Buddynet.bytebuddy.agent.Installer
class.- See Also:
-
INSTALLER_GETTER
The name of the getter fornet.bytebuddy.agent.Installer
to read theInstrumentation
.- See Also:
-
NO_TRANSFORMATION
The value that is to be returned from aClassFileTransformer
to indicate that no class file transformation is to be applied. -
NOT_PREVIOUSLY_DEFINED
A type-safe constant to express that a class is not already loaded when applying a class file transformer. -
DISPATCHER
A dipatcher to use for interacting with the instrumentation API. -
DEFAULT_LOCK
The default circularity lock that assures that no agent created by any agent builder within this class loader causes a class loading circularity. -
byteBuddy
TheByteBuddy
instance to be used. -
listener
The listener to notify on transformations. -
circularityLock
The circularity lock to use. -
poolStrategy
The pool strategy to use. -
typeStrategy
The definition handler to use. -
locationStrategy
The location strategy to use. -
classFileLocator
A class file locator to be used for additional lookup of globally available types. -
nativeMethodStrategy
The native method strategy to use. -
warmupStrategy
The warmup strategy to use. -
transformerDecorator
A decorator to wrap the created class file transformer. -
initializationStrategy
The initialization strategy to use for creating classes. -
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
protected final AgentBuilder.RedefinitionStrategy.ResubmissionStrategy redefinitionResubmissionStrategyThe resubmission strategy to apply. -
injectionStrategy
The injection strategy for injecting classes into a class loader. -
lambdaInstrumentationStrategy
A strategy to determine of theLambdaMetafactory
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. -
classFileBufferStrategy
The class file buffer strategy to use. -
installationListener
The installation listener to notify. -
ignoreMatcher
Identifies types that should not be instrumented. -
transformations
The transformation object for handling type transformations.
-
-
Constructor Details
-
Default
public Default()Creates a new default agent builder that uses a defaultByteBuddy
instance for creating classes. -
Default
Creates a new agent builder with default settings. By default, Byte Buddy ignores any types loaded by the bootstrap class loader, any type within anet.bytebuddy
package and any synthetic type. Self-injection and rebasing is enabled. In order to avoid class format changes, setAgentBuilder.disableClassFormatChanges()
. All types are parsed without their debugging information (AgentBuilder.PoolStrategy.Default.FAST
).- Parameters:
byteBuddy
- The Byte Buddy instance to be used.
-
Default
protected Default(ByteBuddy byteBuddy, AgentBuilder.Listener listener, AgentBuilder.CircularityLock circularityLock, AgentBuilder.PoolStrategy poolStrategy, AgentBuilder.TypeStrategy typeStrategy, AgentBuilder.LocationStrategy locationStrategy, ClassFileLocator classFileLocator, AgentBuilder.Default.NativeMethodStrategy nativeMethodStrategy, AgentBuilder.Default.WarmupStrategy warmupStrategy, AgentBuilder.TransformerDecorator transformerDecorator, AgentBuilder.InitializationStrategy initializationStrategy, AgentBuilder.RedefinitionStrategy redefinitionStrategy, AgentBuilder.RedefinitionStrategy.DiscoveryStrategy redefinitionDiscoveryStrategy, AgentBuilder.RedefinitionStrategy.BatchAllocator redefinitionBatchAllocator, AgentBuilder.RedefinitionStrategy.Listener redefinitionListener, AgentBuilder.RedefinitionStrategy.ResubmissionStrategy redefinitionResubmissionStrategy, AgentBuilder.InjectionStrategy injectionStrategy, AgentBuilder.LambdaInstrumentationStrategy lambdaInstrumentationStrategy, AgentBuilder.DescriptionStrategy descriptionStrategy, AgentBuilder.FallbackStrategy fallbackStrategy, AgentBuilder.ClassFileBufferStrategy classFileBufferStrategy, AgentBuilder.InstallationListener installationListener, AgentBuilder.RawMatcher ignoreMatcher, List<AgentBuilder.Default.Transformation> transformations) Creates a new default agent builder.- Parameters:
byteBuddy
- The Byte Buddy instance to be used.listener
- The listener to notify on transformations.circularityLock
- The circularity lock to use.poolStrategy
- The pool strategy to use.typeStrategy
- The definition handler to use.locationStrategy
- The location strategy to use.classFileLocator
- A class file locator to be used for additional lookup of globally available types.nativeMethodStrategy
- The native method strategy to apply.warmupStrategy
- The warmup strategy to use.transformerDecorator
- A decorator to wrap the created class file transformer.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.injectionStrategy
- The injection strategy for injecting classes into a class loader.lambdaInstrumentationStrategy
- A strategy to determine of theLambdaMetafactory
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.classFileBufferStrategy
- The class file buffer strategy to use.installationListener
- The installation listener to notify.ignoreMatcher
- Identifies types that should not be instrumented.transformations
- The transformations to apply for any non-ignored type.
-
-
Method Details
-
doPrivileged
A proxy forjava.security.AccessController#doPrivileged
that is activated if available.- Type Parameters:
T
- The type of the action's resolved value.- Parameters:
action
- The action to execute from a privileged context.- Returns:
- The action's resolved value.
-
of
Creates anAgentBuilder
that realizes the provided build plugins. AsEntryPoint
,EntryPoint.Default.REBASE
is implied.- Parameters:
plugin
- The build plugins to apply as a Java agent.- Returns:
- An appropriate agent builder.
-
of
Creates anAgentBuilder
that realizes the provided build plugins. AsEntryPoint
,EntryPoint.Default.REBASE
is implied.- Parameters:
plugins
- The build plugins to apply as a Java agent.- Returns:
- An appropriate agent builder.
-
of
Creates anAgentBuilder
that realizes the provided build plugins.- Parameters:
entryPoint
- The build entry point to use.plugin
- The build plugins to apply as a Java agent.- Returns:
- An appropriate agent builder.
-
of
Creates anAgentBuilder
that realizes the provided build plugins.- Parameters:
entryPoint
- The build entry point to use.plugins
- The build plugins to apply as a Java agent.- Returns:
- An appropriate agent builder.
-
of
Creates anAgentBuilder
that realizes the provided build plugins. AsEntryPoint
,EntryPoint.Default.REBASE
is implied.- Parameters:
classFileVersion
- The class file version to use.plugin
- The build plugins to apply as a Java agent.- Returns:
- An appropriate agent builder.
-
of
Creates anAgentBuilder
that realizes the provided build plugins. AsEntryPoint
,EntryPoint.Default.REBASE
is implied.- Parameters:
classFileVersion
- The class file version to use.plugins
- The build plugins to apply as a Java agent.- Returns:
- An appropriate agent builder.
-
of
public static AgentBuilder of(EntryPoint entryPoint, ClassFileVersion classFileVersion, Plugin... plugin) Creates anAgentBuilder
that realizes the provided build plugins.- Parameters:
entryPoint
- The build entry point to use.classFileVersion
- The class file version to use.plugin
- The build plugins to apply as a Java agent.- Returns:
- An appropriate agent builder.
-
of
public static AgentBuilder of(EntryPoint entryPoint, ClassFileVersion classFileVersion, List<? extends Plugin> plugins) Creates anAgentBuilder
that realizes the provided build plugins.- Parameters:
entryPoint
- The build entry point to use.classFileVersion
- The class file version to use.plugins
- The build plugins to apply as a Java agent.- Returns:
- An appropriate agent builder.
-
with
Defines the givenByteBuddy
instance to be used by the created agent.- Specified by:
with
in interfaceAgentBuilder
- Parameters:
byteBuddy
- The Byte Buddy instance to be used.- Returns:
- A new instance of this agent builder which makes use of the given
byteBuddy
instance.
-
with
Defines the givenAgentBuilder.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.- Specified by:
with
in interfaceAgentBuilder
- Parameters:
listener
- The listener to be notified.- Returns:
- A new instance of this agent builder which creates an agent that informs the given listener about events.
-
with
Defines a circularity lock that is acquired upon executing code that potentially loads new classes. While the lock is acquired, any class file transformer refrains from transforming any classes. By default, all created agents use a sharedAgentBuilder.CircularityLock
to avoid that any classes that are required to execute an agent causes aClassCircularityError
.- Specified by:
with
in interfaceAgentBuilder
- Parameters:
circularityLock
- The circularity lock to use.- Returns:
- A new instance of this agent builder which creates an agent that uses the supplied circularity lock.
-
with
Defines how types should be transformed, e.g. if they should be rebased or redefined by the created agent.- Specified by:
with
in interfaceAgentBuilder
- Parameters:
typeStrategy
- The type strategy to use.- Returns:
- A new instance of this agent builder which uses the given type strategy.
-
with
Defines the use of the given type locator for locating aTypeDescription
for an instrumented type.- Specified by:
with
in interfaceAgentBuilder
- Parameters:
poolStrategy
- The type locator to use.- Returns:
- A new instance of this agent builder which uses the given type locator for looking up class files.
-
with
Defines the use of the given location strategy for locating binary data to given class names.- Specified by:
with
in interfaceAgentBuilder
- Parameters:
locationStrategy
- The location strategy to use.- Returns:
- A new instance of this agent builder which uses the given location strategy for looking up class files.
-
with
Description copied from interface:AgentBuilder
Registers an additional class file locator for types that are globally available but cannot be located otherwise. Typically, those types are injected classes into the boot loader.- Specified by:
with
in interfaceAgentBuilder
- Parameters:
classFileLocator
- The class file locator to add.- Returns:
- A new instance of this agent builder which uses the given class file locator for global type lookup.
-
enableNativeMethodPrefix
Enables the use of the given native method prefix for instrumented methods. Note that this prefix is also applied when preserving non-native methods. The use of this prefix is also registered when installing the final agent with anInstrumentation
.- Specified by:
enableNativeMethodPrefix
in interfaceAgentBuilder
- Parameters:
prefix
- The prefix to be used.- Returns:
- A new instance of this agent builder which uses the given native method prefix.
-
disableNativeMethodPrefix
Disables the use of a native method prefix for instrumented methods.- Specified by:
disableNativeMethodPrefix
in interfaceAgentBuilder
- Returns:
- A new instance of this agent builder which does not use a native method prefix.
-
warmUp
Warms up the generated
ClassFileTransformer
to trigger class loading of classes used by the transformer prior to its actual use. Ideally, warmup should include classes that cause a transformation and classes that are ignored. Warming up can be especially useful when transforming classes on the boot path, where circularity errors are more likely. At the same time, warming up might load classes that are expected to be unloaded when this agent is installed.Important: Warming up is applied just as a regular transformation and will also invoke the
AgentBuilder.Listener
. This is done to avoid that listener classes can cause circularities. It is the users responsibility to suppress such log output, if necessary.- Specified by:
warmUp
in interfaceAgentBuilder
- Parameters:
type
- The types to include in the warmup.- Returns:
- A new agent builder that considers the supplied classes in its warmup.
-
warmUp
Warms up the generated
ClassFileTransformer
to trigger class loading of classes used by the transformer prior to its actual use. Ideally, warmup should include classes that cause a transformation and classes that are ignored. Warming up can be especially useful when transforming classes on the boot path, where circularity errors are more likely. At the same time, warming up might load classes that are expected to be unloaded when this agent is installed.Important: Warming up is applied just as a regular transformation and will also invoke the
AgentBuilder.Listener
. This is done to avoid that listener classes can cause circularities. It is the users responsibility to suppress such log output, if necessary.- Specified by:
warmUp
in interfaceAgentBuilder
- Parameters:
types
- The types to include in the warmup.- Returns:
- A new agent builder that considers the supplied classes in its warmup.
-
with
Adds a decorator for the created class file transformer.- Specified by:
with
in interfaceAgentBuilder
- Parameters:
transformerDecorator
- A decorator to wrap the created class file transformer.- Returns:
- A new agent builder that applies the supplied transformer decorator.
-
with
public AgentBuilder.RedefinitionListenable.WithoutBatchStrategy with(AgentBuilder.RedefinitionStrategy redefinitionStrategy) 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()
.- Specified by:
with
in interfaceAgentBuilder
- Parameters:
redefinitionStrategy
- The redefinition strategy to apply.- Returns:
- A new instance of this agent builder that applies the given redefinition strategy.
-
with
Defines a given initialization strategy to be applied to generated types. An initialization strategy is responsible for setting up a type after it was loaded. This initialization must be performed after the transformation because a Java agent is only invoked before loading a type. By default, the initialization logic is added to a class's type initializer which queries a global object for any objects that are to be injected into the generated type.- Specified by:
with
in interfaceAgentBuilder
- Parameters:
initializationStrategy
- The initialization strategy to use.- Returns:
- A new instance of this agent builder that applies the given initialization strategy.
-
with
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 invokeAgentBuilder.LambdaInstrumentationStrategy.release(ClassFileTransformer, Instrumentation)
. Otherwise, the executing VMs class loader retains a reference to the class file transformer what can cause a memory leak.- Specified by:
with
in interfaceAgentBuilder
- Parameters:
lambdaInstrumentationStrategy
-true
if this feature should be enabled.- Returns:
- A new instance of this agent builder where this feature is explicitly enabled or disabled.
-
with
Specifies a strategy to be used for resolvingTypeDescription
for any type handled by the created transformer.- Specified by:
with
in interfaceAgentBuilder
- Parameters:
descriptionStrategy
- The description strategy to use.- Returns:
- A new instance of this agent builder that applies the given description strategy.
-
with
Specifies a fallback strategy to that this agent builder applies upon installing an agent and during class file transformation.- Specified by:
with
in interfaceAgentBuilder
- Parameters:
fallbackStrategy
- The fallback strategy to be used.- Returns:
- A new agent builder that applies the supplied fallback strategy.
-
with
Specifies a class file buffer strategy that determines the use of the buffer supplied to a class file transformer.- Specified by:
with
in interfaceAgentBuilder
- Parameters:
classFileBufferStrategy
- The class file buffer strategy to use.- Returns:
- A new agent builder that applies the supplied class file buffer strategy.
-
with
Adds an installation listener that is notified during installation events. Installation listeners are only invoked if a class file transformer is installed using this agent builder's installation methods and uninstalled via the createdResettableClassFileTransformer
'sreset
methods.- Specified by:
with
in interfaceAgentBuilder
- Parameters:
installationListener
- The installation listener to register.- Returns:
- A new agent builder that applies the supplied installation listener.
-
with
Defines a strategy for injecting auxiliary types into the target class loader.- Specified by:
with
in interfaceAgentBuilder
- Parameters:
injectionStrategy
- The injection strategy to use.- Returns:
- A new agent builder with the supplied injection strategy configured.
-
disableClassFormatChanges
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
andAgentBuilder.TypeStrategy.Default.REDEFINE_FROZEN
(unless it is configured asAgentBuilder.TypeStrategy.Default.DECORATE
where this strategy is retained) as well as configuring the underlyingByteBuddy
instance to use aImplementation.Context.Disabled
. Using this strategy also configures Byte Buddy to create frozen instrumented types and discards any explicit configuration.- Specified by:
disableClassFormatChanges
in interfaceAgentBuilder
- Returns:
- A new instance of this agent builder that does not apply any implicit changes to the received class file.
-
assureReadEdgeTo
Assures that all modules of the supplied types are read by the module of any instrumented type. If the current VM does not support the Java module system, calling this method has no effect and this instance is returned.- Specified by:
assureReadEdgeTo
in interfaceAgentBuilder
- Parameters:
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.- Returns:
- A new instance of this agent builder that assures the supplied types module visibility.
- See Also:
-
assureReadEdgeTo
Assures that all supplied modules are read by the module of any instrumented type.- Specified by:
assureReadEdgeTo
in interfaceAgentBuilder
- Parameters:
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.- Returns:
- A new instance of this agent builder that assures the supplied types module visibility.
- See Also:
-
assureReadEdgeTo
public AgentBuilder assureReadEdgeTo(Instrumentation instrumentation, Collection<? extends JavaModule> modules) Assures that all supplied modules are read by the module of any instrumented type.- Specified by:
assureReadEdgeTo
in interfaceAgentBuilder
- Parameters:
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.- Returns:
- A new instance of this agent builder that assures the supplied types module visibility.
- See Also:
-
assureReadEdgeFromAndTo
Assures that all modules of the supplied types are read by the module of any instrumented type and vice versa. If the current VM does not support the Java module system, calling this method has no effect and this instance is returned. Setting this option will also ensure that the instrumented type's package is opened to the target module, if applicable.- Specified by:
assureReadEdgeFromAndTo
in interfaceAgentBuilder
- Parameters:
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.- Returns:
- A new instance of this agent builder that assures the supplied types module visibility.
- See Also:
-
assureReadEdgeFromAndTo
Assures that all supplied modules are read by the module of any instrumented type and vice versa. Setting this option will also ensure that the instrumented type's package is opened to the target module.- Specified by:
assureReadEdgeFromAndTo
in interfaceAgentBuilder
- Parameters:
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.- Returns:
- A new instance of this agent builder that assures the supplied types module visibility.
- See Also:
-
assureReadEdgeFromAndTo
public 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. Setting this option will also ensure that the instrumented type's package is opened to the target module.- Specified by:
assureReadEdgeFromAndTo
in interfaceAgentBuilder
- Parameters:
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.- Returns:
- A new instance of this agent builder that assures the supplied types module visibility.
- See Also:
-
type
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, any matcher is executed in registration order with matchers that were registered first being executed first. Doing so, later transformations can override transformations that are applied by this matcher. To avoid this, it is possible to register this transformation as terminal via
AgentBuilder.Identified.Extendable.asTerminalTransformation()
where no subsequent matchers are applied if this matcher matched a given type.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.- Specified by:
type
in interfaceAgentBuilder
- Parameters:
matcher
- A matcher that decides if the entailedAgentBuilder.Transformer
s should be applied for a type that is being loaded.- Returns:
- A definable that represents this agent builder which allows for the definition of one or several
AgentBuilder.Transformer
s to be applied when the givenmatcher
indicates a match.
-
type
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, any matcher is executed in registration order with matchers that were registered first being executed first. Doing so, later transformations can override transformations that are applied by this matcher. To avoid this, it is possible to register this transformation as terminal via
AgentBuilder.Identified.Extendable.asTerminalTransformation()
where no subsequent matchers are applied if this matcher matched a given type.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 usingAgentBuilder.type(ElementMatcher, ElementMatcher)
instead.- Specified by:
type
in interfaceAgentBuilder
- Parameters:
typeMatcher
- AnElementMatcher
that is applied on the type being loaded that decides if the entailedAgentBuilder.Transformer
s should be applied for that type.- Returns:
- A definable that represents this agent builder which allows for the definition of one or several
AgentBuilder.Transformer
s to be applied when the giventypeMatcher
indicates a match.
-
type
public 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. 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, any matcher is executed in registration order with matchers that were registered first being executed first. Doing so, later transformations can override transformations that are applied by this matcher. To avoid this, it is possible to register this transformation as terminal via
AgentBuilder.Identified.Extendable.asTerminalTransformation()
where no subsequent matchers are applied if this matcher matched a given type.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.- Specified by:
type
in interfaceAgentBuilder
- Parameters:
typeMatcher
- AnElementMatcher
that is applied on the type being loaded that decides if the entailedAgentBuilder.Transformer
s should be applied for that type.classLoaderMatcher
- AnElementMatcher
that is applied to theClassLoader
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.- Returns:
- A definable that represents this agent builder which allows for the definition of one or several
AgentBuilder.Transformer
s to be applied when both the giventypeMatcher
andclassLoaderMatcher
indicate a match.
-
type
public 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. 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, any matcher is executed in registration order with matchers that were registered first being executed first. Doing so, later transformations can override transformations that are applied by this matcher. To avoid this, it is possible to register this transformation as terminal via
AgentBuilder.Identified.Extendable.asTerminalTransformation()
where no subsequent matchers are applied if this matcher matched a given type.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.- Specified by:
type
in interfaceAgentBuilder
- Parameters:
typeMatcher
- AnElementMatcher
that is applied on the type being loaded that decides if the entailedAgentBuilder.Transformer
s should be applied for that type.classLoaderMatcher
- AnElementMatcher
that is applied to theClassLoader
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
- AnElementMatcher
that is applied to theJavaModule
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.- Returns:
- A definable that represents this agent builder which allows for the definition of one or several
AgentBuilder.Transformer
s to be applied when both the giventypeMatcher
andclassLoaderMatcher
indicate a match.
-
ignore
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 aAgentBuilder.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.- Specified by:
ignore
in interfaceAgentBuilder
- Parameters:
typeMatcher
- A matcher that identifies types that should not be instrumented.- Returns:
- A new instance of this agent builder that ignores all types that are matched by the provided matcher. All previous matchers for ignored types are discarded.
-
ignore
public 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. 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 aAgentBuilder.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.- Specified by:
ignore
in interfaceAgentBuilder
- Parameters:
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.- Returns:
- A new instance of this agent builder that ignores all types that are matched by the provided matcher. All previous matchers for ignored types are discarded.
-
ignore
public 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. 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 aAgentBuilder.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.- Specified by:
ignore
in interfaceAgentBuilder
- Parameters:
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.- Returns:
- A new instance of this agent builder that ignores all types that are matched by the provided matcher. All previous matchers for ignored types are discarded.
-
ignore
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 aAgentBuilder.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.- Specified by:
ignore
in interfaceAgentBuilder
- Parameters:
rawMatcher
- A raw matcher that identifies types that should not be instrumented.- Returns:
- A new instance of this agent builder that ignores all types that are matched by the provided matcher. All previous matchers for ignored types are discarded.
-
makeRaw
Creates aResettableClassFileTransformer
that implements the configuration of this agent builder. When using a raw class file transformer, theAgentBuilder.InstallationListener
callbacks are not invoked and the setAgentBuilder.RedefinitionStrategy
is not applied onto currently loaded classes.- Specified by:
makeRaw
in interfaceAgentBuilder
- Returns:
- A class file transformer that implements the configuration of this agent builder.
-
makeRaw
private ResettableClassFileTransformer makeRaw(AgentBuilder.Listener listener, AgentBuilder.InstallationListener installationListener, AgentBuilder.RedefinitionStrategy.ResubmissionEnforcer resubmissionEnforcer) Creates a new class file transformer with a given listener.- Parameters:
listener
- The listener to supply.installationListener
- The installation listener to notify.resubmissionEnforcer
- The resubmission enforcer to use.- Returns:
- The resettable class file transformer to use.
-
resolveByteBuddyAgentInstrumentation
Resolves the instrumentation provided bynet.bytebuddy.agent.Installer
.- Returns:
- The installed instrumentation instance.
-
installOn
Creates and installs a
ResettableClassFileTransformer
that implements the configuration of this agent builder with a givenInstrumentation
. 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 theResettableClassFileTransformer
'sreset
methods.- Specified by:
installOn
in interfaceAgentBuilder
- Parameters:
instrumentation
- The instrumentation on which this agent builder's configuration is to be installed.- Returns:
- The installed class file transformer.
-
installOnByteBuddyAgent
Creates and installs a
ResettableClassFileTransformer
that implements the configuration of this agent builder with the Byte Buddy-agent which must be installed prior to calling this method. 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 theResettableClassFileTransformer
'sreset
methods.- Specified by:
installOnByteBuddyAgent
in interfaceAgentBuilder
- Returns:
- The installed class file transformer.
- See Also:
-
patchOn
public ResettableClassFileTransformer patchOn(Instrumentation instrumentation, ResettableClassFileTransformer classFileTransformer) Creates and installs a
ResettableClassFileTransformer
that implements the configuration of this agent builder with a givenInstrumentation
. If retransformation is enabled, the installation also causes all loaded types to be retransformed which have changed compared to the previous class file transformer that is provided as an argument. Without specification,AgentBuilder.PatchMode.OVERLAP
is used.In order to assure the correct handling of the
AgentBuilder.InstallationListener
, an uninstallation should be applied via theResettableClassFileTransformer
'sreset
methods.- Specified by:
patchOn
in interfaceAgentBuilder
- Parameters:
instrumentation
- The instrumentation on which this agent builder's configuration is to be installed.classFileTransformer
- The class file transformer that is being patched.- Returns:
- The installed class file transformer.
-
patchOn
public ResettableClassFileTransformer patchOn(Instrumentation instrumentation, ResettableClassFileTransformer classFileTransformer, AgentBuilder.PatchMode patchMode) Creates and installs a
ResettableClassFileTransformer
that implements the configuration of this agent builder with a givenInstrumentation
. If retransformation is enabled, the installation also causes all loaded types to be retransformed which have changed compared to the previous class file transformer that is provided as an argument.In order to assure the correct handling of the
AgentBuilder.InstallationListener
, an uninstallation should be applied via theResettableClassFileTransformer
'sreset
methods.- Specified by:
patchOn
in interfaceAgentBuilder
- Parameters:
instrumentation
- The instrumentation on which this agent builder's configuration is to be installed.classFileTransformer
- The class file transformer that is being patched.patchMode
- The patch mode to apply.- Returns:
- The installed class file transformer.
-
patchOnByteBuddyAgent
public ResettableClassFileTransformer patchOnByteBuddyAgent(ResettableClassFileTransformer classFileTransformer) Creates and installs a
ResettableClassFileTransformer
that implements the configuration of this agent builder with the Byte Buddy-agent which must be installed prior to calling this method. If retransformation is enabled, the installation also causes all loaded types to be retransformed which have changed compared to the previous class file transformer that is provided as an argument. Without specification,AgentBuilder.PatchMode.OVERLAP
is used.In order to assure the correct handling of the
AgentBuilder.InstallationListener
, an uninstallation should be applied via theResettableClassFileTransformer
'sreset
methods.- Specified by:
patchOnByteBuddyAgent
in interfaceAgentBuilder
- Parameters:
classFileTransformer
- The class file transformer that is being patched.- Returns:
- The installed class file transformer.
- See Also:
-
patchOnByteBuddyAgent
public ResettableClassFileTransformer patchOnByteBuddyAgent(ResettableClassFileTransformer classFileTransformer, AgentBuilder.PatchMode patchMode) Creates and installs a
ResettableClassFileTransformer
that implements the configuration of this agent builder with the Byte Buddy-agent which must be installed prior to calling this method. If retransformation is enabled, the installation also causes all loaded types to be retransformed which have changed compared to the previous class file transformer that is provided as an argument.In order to assure the correct handling of the
AgentBuilder.InstallationListener
, an uninstallation should be applied via theResettableClassFileTransformer
'sreset
methods.- Specified by:
patchOnByteBuddyAgent
in interfaceAgentBuilder
- Parameters:
classFileTransformer
- The class file transformer that is being patched.patchMode
- The patch mode to apply.- Returns:
- The installed class file transformer.
- See Also:
-
doInstall
private ResettableClassFileTransformer doInstall(Instrumentation instrumentation, AgentBuilder.RawMatcher matcher, AgentBuilder.PatchMode.Handler handler) Installs the class file transformer.- Parameters:
instrumentation
- The instrumentation to install the matcher on.matcher
- The matcher to identify redefined types.handler
- The handler to use for implementing a patch mode.- Returns:
- The created class file transformer.
-