An agent builder provides a convenience API for defining a
Java agent. By default,
this transformation is applied by rebasing the type if not specified otherwise by setting a
TypeStrategy.
When defining several net.s, the agent builder always
applies the transformers that were supplied with the last applicable matcher. Therefore, more general transformers
should be defined first.
Note
Any transformation is performed using the java.security.AccessControlContext of an agent's creator.
Important Note
Types that implement lambda expressions (functional interfaces) are not instrumented by default but
only when enabling the builder's LambdaInstrumentationStrategy.
| Modifier and Type | Class and Description |
|---|---|
| public static interface | AgentBuilder.CircularityLock
A circularity lock is responsible for preventing that a |
| public static interface | AgentBuilder.ClassFileBufferStrategy
This strategy determines how the provided class file buffer is used. |
| public static class | AgentBuilder.Default
The default implementation of an |
| public static interface | AgentBuilder.DescriptionStrategy
A description strategy is responsible for resolving a |
| public static interface | AgentBuilder.FallbackStrategy
A fallback strategy allows to reattempt a transformation or a consideration for redefinition/retransformation in case an exception occurs. |
| public static interface | AgentBuilder.Identified
Describes an |
| public static interface | AgentBuilder.Ignored
Allows to further specify ignored types. |
| public static interface | AgentBuilder.InitializationStrategy
An initialization strategy which determines the handling of |
| public static interface | AgentBuilder.InjectionStrategy
A strategy for injecting auxiliary types into a class loader. |
| public static interface | AgentBuilder.InstallationListener
A listener that is notified during the installation and the resetting of a class file transformer. |
| public static enum | AgentBuilder.LambdaInstrumentationStrategy
Implements the instrumentation of the |
| public static interface | AgentBuilder.Listener
A listener that is informed about events that occur during an instrumentation process. |
| public static interface | AgentBuilder.LocationStrategy
A strategy for creating a |
| public static interface | AgentBuilder.Matchable<
The type that is produced by chaining a matcher. T extends AgentBuilder.An abstraction for extending a matcher. |
| public static enum | AgentBuilder.PatchMode
Determines how patching a |
| public static interface | AgentBuilder.PoolStrategy
A type locator allows to specify how |
| public static interface | AgentBuilder.RawMatcher
A matcher that allows to determine if a |
| public static interface | AgentBuilder.RedefinitionListenable
An agent builder configuration that allows the registration of listeners to the redefinition process. |
| public static enum | AgentBuilder.RedefinitionStrategy
A redefinition strategy regulates how already loaded classes are modified by a built agent. |
| public static interface | AgentBuilder.Transformer
A transformer allows to apply modifications to a |
| public static interface | AgentBuilder.TransformerDecorator
A decorator that allows to change the class file transformer that is registered. |
| public static interface | AgentBuilder.TypeStrategy
A type strategy is responsible for creating a type builder for a type that is being instrumented. |
| Modifier and Type | Method and Description |
|---|---|
| public AgentBuilder | Returns: A new instance of this agent builder that assures the supplied types module visibility.The instrumentation instance that is used for adding a module read-dependency. instrumentation, Class<?>... The types for which to assure their module-visibility from and to any instrumented class. type)Assures that all modules of the supplied types are read by the module of any instrumented type and vice versa. |
| public AgentBuilder | Returns: A new instance of this agent builder that assures the supplied types module visibility.The instrumentation instance that is used for adding a module read-dependency. instrumentation, JavaModule... The modules for which to assure their module-visibility from and to any instrumented class. module)Assures that all supplied modules are read by the module of any instrumented type and vice versa. |
| public AgentBuilder | Returns: A new instance of this agent builder that assures the supplied types module visibility.The instrumentation instance that is used for adding a module read-dependency. instrumentation, Collection<? extends JavaModule> The modules for which to assure their module-visibility from and to any instrumented class. modules)Assures that all supplied modules are read by the module of any instrumented type and vice versa. |
| public AgentBuilder | Returns: A new instance of this agent builder that assures the supplied types module visibility.The instrumentation instance that is used for adding a module read-dependency. instrumentation, Class<?>... The types for which to assure their module-visibility from any instrumented class. type)Assures that all modules of the supplied types are read by the module of any instrumented type. |
| public AgentBuilder | Returns: A new instance of this agent builder that assures the supplied types module visibility.The instrumentation instance that is used for adding a module read-dependency. instrumentation, JavaModule... The modules for which to assure their module-visibility from any instrumented class. module)Assures that all supplied modules are read by the module of any instrumented type. |
| public AgentBuilder | Returns: A new instance of this agent builder that assures the supplied types module visibility.The instrumentation instance that is used for adding a module read-dependency. instrumentation, Collection<? extends JavaModule> The modules for which to assure their module-visibility from any instrumented class. modules)Assures that all supplied modules are read by the module of any instrumented type. |
| public AgentBuilder | Returns: A new instance of this agent builder that does not apply any implicit changes to the received class file.Disables all implicit changes on a class file that Byte Buddy would apply for certain instrumentations. |
| public AgentBuilder | Returns: A new instance of this agent builder which does not use a native method prefix.Disables the use of a native method prefix for instrumented methods. |
| public AgentBuilder | Returns: A new instance of this agent builder which uses the given native method prefix.The prefix to be used. prefix)Enables the use of the given native method prefix for instrumented methods. |
| public AgentBuilder. | 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.A matcher that identifies types that should not be instrumented. typeMatcher)
Excludes any type that is matched by the provided matcher from instrumentation and considers types by all |
| public AgentBuilder. | 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.A matcher that identifies types that should not be instrumented. typeMatcher, ElementMatcher<? super ClassLoader> A matcher that identifies a class loader that identifies classes that should not be instrumented. classLoaderMatcher)Excludes any type that is matched by the provided matcher and is loaded by a class loader matching the second matcher. |
| public AgentBuilder. | 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.A matcher that identifies types that should not be instrumented. typeMatcher, ElementMatcher<? super ClassLoader> A matcher that identifies a class loader that identifies classes that should not be instrumented. classLoaderMatcher, ElementMatcher<? super JavaModule> 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. moduleMatcher)Excludes any type that is matched by the provided matcher and is loaded by a class loader matching the second matcher. |
| public AgentBuilder. | 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.A raw matcher that identifies types that should not be instrumented. rawMatcherExcludes any type that is matched by the raw matcher provided to this method. |
| public ResettableClassFileTransformer | Returns: The installed class file transformer.The instrumentation on which this agent builder's configuration is to be installed. instrumentation)
Creates and installs a |
| public ResettableClassFileTransformer | Returns: The installed class file transformer.
Creates and installs a |
| public ClassFileTransformer | Returns: A class file transformer that implements the configuration of this agent builder.Creates a |
| public ResettableClassFileTransformer | Returns: The installed class file transformer.The instrumentation on which this agent builder's configuration is to be installed. instrumentation, ResettableClassFileTransformer The class file transformer that is being patched. classFileTransformer)
Creates and installs a |
| public ResettableClassFileTransformer | Returns: The installed class file transformer.The instrumentation on which this agent builder's configuration is to be installed. instrumentation, ResettableClassFileTransformer The class file transformer that is being patched. classFileTransformer, AgentBuilder.The differential matcher to decide what types need retransformation. differentialMatcher
Creates and installs a |
| public ResettableClassFileTransformer | Returns: The installed class file transformer.The instrumentation on which this agent builder's configuration is to be installed. instrumentation, ResettableClassFileTransformer The class file transformer that is being patched. classFileTransformer, AgentBuilder.The patch mode to apply. patchMode
Creates and installs a |
| public ResettableClassFileTransformer | Returns: The installed class file transformer.The instrumentation on which this agent builder's configuration is to be installed. instrumentation, ResettableClassFileTransformer The class file transformer that is being patched. classFileTransformer, AgentBuilder.The differential matcher to decide what types need retransformation. differentialMatcher,The patch mode to apply. patchMode
Creates and installs a |
| public ResettableClassFileTransformer | Returns: The installed class file transformer.The class file transformer that is being patched. classFileTransformer)
Creates and installs a |
| public ResettableClassFileTransformer | Returns: The installed class file transformer.The class file transformer that is being patched. classFileTransformer, AgentBuilder.The patch mode to apply. patchMode
Creates and installs a |
| public AgentBuilder. | Returns: A definable that represents this agent builder which allows for the definition of one or severalnet.s to be applied when the given typeMatcher
indicates a match.An typeMatcher)net. that is applied on the type being loaded that
decides if the entailed net.s should
be applied for that type.
Matches a type being loaded in order to apply the supplied |
| public AgentBuilder. | Returns: A definable that represents this agent builder which allows for the definition of one or severalnet.s to be applied when both the given
typeMatcher and classLoaderMatcher indicate a match.An typeMatcher, ElementMatcher<? super ClassLoader> net. that is applied on the type being
loaded that decides if the entailed
net.s should be applied for
that type.An classLoaderMatcher)net. that is applied to the
java. 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.
Matches a type being loaded in order to apply the supplied |
| public AgentBuilder. | Returns: A definable that represents this agent builder which allows for the definition of one or severalnet.s to be applied when both the given
typeMatcher and classLoaderMatcher indicate a match.An typeMatcher, ElementMatcher<? super ClassLoader> net. that is applied on the type being
loaded that decides if the entailed
net.s should be applied for
that type.An classLoaderMatcher, ElementMatcher<? super JavaModule> net. that is applied to the
java. 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.An moduleMatcher)net. 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.
Matches a type being loaded in order to apply the supplied |
| public AgentBuilder. | Returns: A definable that represents this agent builder which allows for the definition of one or severalnet.s to be applied when the given matcher
indicates a match.A matcher that decides if the entailed matchernet.s should be
applied for a type that is being loaded.
Matches a type being loaded in order to apply the supplied |
| public AgentBuilder | Returns: A new agent builder that considers the supplied classes in its warmup.The types to include in the warmup. type)
Warms up the generated |
| public AgentBuilder | Returns: A new agent builder that considers the supplied classes in its warmup.The types to include in the warmup. types)
Warms up the generated |
| public AgentBuilder | Returns: A new instance of this agent builder which makes use of the givenbyteBuddy instance.The Byte Buddy instance to be used. byteBuddy)Defines the given |
| public AgentBuilder | Returns: A new instance of this agent builder which creates an agent that informs the given listener about events.The listener to be notified. listenerDefines the given |
| public AgentBuilder | Returns: A new instance of this agent builder which creates an agent that uses the supplied circularity lock.The circularity lock to use. circularityLockDefines a circularity lock that is acquired upon executing code that potentially loads new classes. |
| public AgentBuilder | Returns: A new instance of this agent builder which uses the given type locator for looking up class files.The type locator to use. poolStrategyDefines the use of the given type locator for locating a |
| public AgentBuilder | Returns: A new instance of this agent builder which uses the given location strategy for looking up class files.The location strategy to use. locationStrategyDefines the use of the given location strategy for locating binary data to given class names. |
| public AgentBuilder | Returns: A new instance of this agent builder which uses the given class file locator for global type lookup.The class file locator to add. classFileLocator)Registers an additional class file locator for types that are globally available but cannot be located otherwise. |
| public AgentBuilder | Returns: A new instance of this agent builder which uses the given type strategy.The type strategy to use. typeStrategyDefines how types should be transformed, e.g. if they should be rebased or redefined by the created agent. |
| public AgentBuilder | Returns: A new instance of this agent builder that applies the given initialization strategy.The initialization strategy to use. initializationStrategyDefines a given initialization strategy to be applied to generated types. |
| public AgentBuilder. | Returns: A new instance of this agent builder that applies the given redefinition strategy.The redefinition strategy to apply. redefinitionStrategySpecifies a strategy for modifying types that were already loaded prior to the installation of this transformer. |
| public AgentBuilder | Returns: A new instance of this agent builder where this feature is explicitly enabled or disabled.true if this feature should be enabled.
Enables or disables management of the JVM's |
| public AgentBuilder | Returns: A new instance of this agent builder that applies the given description strategy.The description strategy to use. descriptionStrategySpecifies a strategy to be used for resolving |
| public AgentBuilder | Returns: A new agent builder that applies the supplied fallback strategy.The fallback strategy to be used. fallbackStrategySpecifies a fallback strategy to that this agent builder applies upon installing an agent and during class file transformation. |
| public AgentBuilder | Returns: A new agent builder that applies the supplied class file buffer strategy.The class file buffer strategy to use. classFileBufferStrategySpecifies a class file buffer strategy that determines the use of the buffer supplied to a class file transformer. |
| public AgentBuilder | Returns: A new agent builder that applies the supplied installation listener.The installation listener to register. installationListenerAdds an installation listener that is notified during installation events. |
| public AgentBuilder | Returns: A new agent builder with the supplied injection strategy configured.The injection strategy to use. injectionStrategyDefines a strategy for injecting auxiliary types into the target class loader. |
| public AgentBuilder | Returns: A new agent builder that applies the supplied transformer decorator.A decorator to wrap the created class file transformer. transformerDecoratorAdds a decorator for the created class file transformer. |