Class AgentBuilder.Default.Delegator<T extends AgentBuilder.Matchable<T>>
- java.lang.Object
-
- net.bytebuddy.agent.builder.AgentBuilder.Matchable.AbstractBase<T>
-
- net.bytebuddy.agent.builder.AgentBuilder.Default.Delegator<T>
-
- Type Parameters:
T- The type that is produced by chaining a matcher.
- All Implemented Interfaces:
AgentBuilder,AgentBuilder.Matchable<T>
- Direct Known Subclasses:
AgentBuilder.Default.Ignoring,AgentBuilder.Default.Transforming
- Enclosing class:
- AgentBuilder.Default
protected abstract class AgentBuilder.Default.Delegator<T extends AgentBuilder.Matchable<T>> extends AgentBuilder.Matchable.AbstractBase<T> implements AgentBuilder
An abstract implementation of an agent builder that delegates all invocation to another instance.
-
-
Nested Class Summary
-
Nested classes/interfaces inherited from interface net.bytebuddy.agent.builder.AgentBuilder
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
-
Nested classes/interfaces inherited from interface net.bytebuddy.agent.builder.AgentBuilder.Matchable
AgentBuilder.Matchable.AbstractBase<S extends AgentBuilder.Matchable<S>>
-
-
Constructor Summary
Constructors Modifier Constructor Description protectedDelegator()
-
Method Summary
All Methods Instance Methods Abstract Methods Concrete Methods Modifier and Type Method Description AgentBuilderassureReadEdgeFromAndTo(java.lang.instrument.Instrumentation instrumentation, java.lang.Class<?>... type)Assures that all modules of the supplied types are read by the module of any instrumented type and vice versa.AgentBuilderassureReadEdgeFromAndTo(java.lang.instrument.Instrumentation instrumentation, java.util.Collection<? extends JavaModule> modules)Assures that all supplied modules are read by the module of any instrumented type and vice versa.AgentBuilderassureReadEdgeFromAndTo(java.lang.instrument.Instrumentation instrumentation, JavaModule... module)Assures that all supplied modules are read by the module of any instrumented type and vice versa.AgentBuilderassureReadEdgeTo(java.lang.instrument.Instrumentation instrumentation, java.lang.Class<?>... type)Assures that all modules of the supplied types are read by the module of any instrumented type.AgentBuilderassureReadEdgeTo(java.lang.instrument.Instrumentation instrumentation, java.util.Collection<? extends JavaModule> modules)Assures that all supplied modules are read by the module of any instrumented type.AgentBuilderassureReadEdgeTo(java.lang.instrument.Instrumentation instrumentation, JavaModule... module)Assures that all supplied modules are read by the module of any instrumented type.AgentBuilderdisableBootstrapInjection()Disables injection of auxiliary classes into the bootstrap class path.AgentBuilderdisableClassFormatChanges()Disables all implicit changes on a class file that Byte Buddy would apply for certain instrumentations.AgentBuilderdisableNativeMethodPrefix()Disables the use of a native method prefix for instrumented methods.AgentBuilderenableBootstrapInjection(java.lang.instrument.Instrumentation instrumentation, java.io.File folder)Enables class injection of auxiliary classes into the bootstrap class loader.AgentBuilderenableNativeMethodPrefix(java.lang.String prefix)Enables the use of the given native method prefix for instrumented methods.AgentBuilderenableUnsafeBootstrapInjection()Enables class injection of auxiliary classes into the bootstrap class loader which relies onsun.misc.Unsafe.AgentBuilder.Ignoredignore(AgentBuilder.RawMatcher rawMatcher)Excludes any type that is matched by the raw matcher provided to this method.AgentBuilder.Ignoredignore(ElementMatcher<? super TypeDescription> ignoredTypes)Excludes any type that is matched by the provided matcher from instrumentation and considers types by allClassLoaders.AgentBuilder.Ignoredignore(ElementMatcher<? super TypeDescription> ignoredTypes, ElementMatcher<? super java.lang.ClassLoader> ignoredClassLoaders)Excludes any type that is matched by the provided matcher and is loaded by a class loader matching the second matcher.AgentBuilder.Ignoredignore(ElementMatcher<? super TypeDescription> typeMatcher, ElementMatcher<? super java.lang.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.ResettableClassFileTransformerinstallOn(java.lang.instrument.Instrumentation instrumentation)Creates and installs aClassFileTransformerthat implements the configuration of this agent builder with a givenInstrumentation.ResettableClassFileTransformerinstallOnByteBuddyAgent()Creates and installs aClassFileTransformerthat implements the configuration of this agent builder with the Byte Buddy-agent which must be installed prior to calling this method.java.lang.instrument.ClassFileTransformermakeRaw()Creates aClassFileTransformerthat implements the configuration of this agent builder.protected abstract AgentBuildermaterialize()Materializes the currently describedAgentBuilder.AgentBuilder.Identified.Narrowabletype(AgentBuilder.RawMatcher matcher)Matches a type being loaded in order to apply the suppliedAgentBuilder.Transformers before loading this type.AgentBuilder.Identified.Narrowabletype(ElementMatcher<? super TypeDescription> typeMatcher)Matches a type being loaded in order to apply the suppliedAgentBuilder.Transformers before loading this type.AgentBuilder.Identified.Narrowabletype(ElementMatcher<? super TypeDescription> typeMatcher, ElementMatcher<? super java.lang.ClassLoader> classLoaderMatcher)Matches a type being loaded in order to apply the suppliedAgentBuilder.Transformers before loading this type.AgentBuilder.Identified.Narrowabletype(ElementMatcher<? super TypeDescription> typeMatcher, ElementMatcher<? super java.lang.ClassLoader> classLoaderMatcher, ElementMatcher<? super JavaModule> moduleMatcher)Matches a type being loaded in order to apply the suppliedAgentBuilder.Transformers before loading this type.AgentBuilderwith(AgentBuilder.CircularityLock circularityLock)Defines a circularity lock that is acquired upon executing code that potentially loads new classes.AgentBuilderwith(AgentBuilder.DescriptionStrategy descriptionStrategy)Specifies a strategy to be used for resolvingTypeDescriptionfor any type handled by the created transformer.AgentBuilderwith(AgentBuilder.FallbackStrategy fallbackStrategy)Specifies a fallback strategy to that this agent builder applies upon installing an agent and during class file transformation.AgentBuilderwith(AgentBuilder.InitializationStrategy initializationStrategy)Defines a given initialization strategy to be applied to generated types.AgentBuilderwith(AgentBuilder.InstallationListener installationListener)Adds an installation listener that is notified during installation events.AgentBuilderwith(AgentBuilder.LambdaInstrumentationStrategy lambdaInstrumentationStrategy)Enables or disables management of the JVM'sLambdaMetafactorywhich is responsible for creating classes that implement lambda expressions.AgentBuilderwith(AgentBuilder.Listener listener)Defines the givenAgentBuilder.Listenerto be notified by the created agent.AgentBuilderwith(AgentBuilder.LocationStrategy locationStrategy)Defines the use of the given location strategy for locating binary data to given class names.AgentBuilderwith(AgentBuilder.PoolStrategy poolStrategy)Defines the use of the given type locator for locating aTypeDescriptionfor an instrumented type.AgentBuilder.RedefinitionListenable.WithoutBatchStrategywith(AgentBuilder.RedefinitionStrategy redefinitionStrategy)Specifies a strategy for modifying types that were already loaded prior to the installation of this transformer.AgentBuilderwith(AgentBuilder.TypeStrategy typeStrategy)Defines how types should be transformed, e.g.AgentBuilderwith(ByteBuddy byteBuddy)Defines the givenByteBuddyinstance to be used by the created agent.-
Methods inherited from class net.bytebuddy.agent.builder.AgentBuilder.Matchable.AbstractBase
and, and, and, or, or, or
-
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
-
Methods inherited from interface net.bytebuddy.agent.builder.AgentBuilder.Matchable
and, or
-
-
-
-
Method Detail
-
materialize
protected abstract AgentBuilder materialize()
Materializes the currently describedAgentBuilder.- Returns:
- An agent builder that represents the currently described entry of this instance.
-
with
public AgentBuilder with(ByteBuddy byteBuddy)
Description copied from interface:AgentBuilderDefines the givenByteBuddyinstance to be used by the created agent.- Specified by:
within interfaceAgentBuilder- Parameters:
byteBuddy- The Byte Buddy instance to be used.- Returns:
- A new instance of this agent builder which makes use of the given
byteBuddyinstance.
-
with
public AgentBuilder with(AgentBuilder.Listener listener)
Description copied from interface:AgentBuilderDefines the givenAgentBuilder.Listenerto 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:
within 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
public AgentBuilder with(AgentBuilder.CircularityLock circularityLock)
Description copied from interface:AgentBuilderDefines 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.CircularityLockto avoid that any classes that are required to execute an agent causes aClassCircularityError.- Specified by:
within 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
public AgentBuilder with(AgentBuilder.TypeStrategy typeStrategy)
Description copied from interface:AgentBuilderDefines how types should be transformed, e.g. if they should be rebased or redefined by the created agent.- Specified by:
within interfaceAgentBuilder- Parameters:
typeStrategy- The type strategy to use.- Returns:
- A new instance of this agent builder which uses the given type strategy.
-
with
public AgentBuilder with(AgentBuilder.PoolStrategy poolStrategy)
Description copied from interface:AgentBuilderDefines the use of the given type locator for locating aTypeDescriptionfor an instrumented type.- Specified by:
within 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
public AgentBuilder with(AgentBuilder.LocationStrategy locationStrategy)
Description copied from interface:AgentBuilderDefines the use of the given location strategy for locating binary data to given class names.- Specified by:
within 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
public AgentBuilder with(AgentBuilder.InitializationStrategy initializationStrategy)
Description copied from interface:AgentBuilderDefines 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:
within interfaceAgentBuilder- Parameters:
initializationStrategy- The initialization strategy to use.- Returns:
- A new instance of this agent builder that applies the given initialization strategy.
-
with
public AgentBuilder.RedefinitionListenable.WithoutBatchStrategy with(AgentBuilder.RedefinitionStrategy redefinitionStrategy)
Description copied from interface:AgentBuilderSpecifies 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:
within interfaceAgentBuilder- Parameters:
redefinitionStrategy- The redefinition strategy to apply.- Returns:
- A new instance of this agent builder that applies the given redefinition strategy.
-
with
public AgentBuilder with(AgentBuilder.LambdaInstrumentationStrategy lambdaInstrumentationStrategy)
Description copied from interface:AgentBuilderEnables or disables management of the JVM's
LambdaMetafactorywhich 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
LambdaMetafactoryand 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:
within interfaceAgentBuilder- Parameters:
lambdaInstrumentationStrategy-trueif this feature should be enabled.- Returns:
- A new instance of this agent builder where this feature is explicitly enabled or disabled.
-
with
public AgentBuilder with(AgentBuilder.DescriptionStrategy descriptionStrategy)
Description copied from interface:AgentBuilderSpecifies a strategy to be used for resolvingTypeDescriptionfor any type handled by the created transformer.- Specified by:
within interfaceAgentBuilder- Parameters:
descriptionStrategy- The description strategy to use.- Returns:
- A new instance of this agent builder that applies the given description strategy.
-
with
public AgentBuilder with(AgentBuilder.FallbackStrategy fallbackStrategy)
Description copied from interface:AgentBuilderSpecifies a fallback strategy to that this agent builder applies upon installing an agent and during class file transformation.- Specified by:
within interfaceAgentBuilder- Parameters:
fallbackStrategy- The fallback strategy to be used.- Returns:
- A new agent builder that applies the supplied fallback strategy.
-
with
public AgentBuilder with(AgentBuilder.InstallationListener installationListener)
Description copied from interface:AgentBuilderAdds 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'sresetmethods.- Specified by:
within interfaceAgentBuilder- Parameters:
installationListener- The installation listener to register.- Returns:
- A new agent builder that applies the supplied installation listener.
-
enableBootstrapInjection
public AgentBuilder enableBootstrapInjection(java.lang.instrument.Instrumentation instrumentation, java.io.File folder)
Description copied from interface:AgentBuilderEnables class injection of auxiliary classes into the bootstrap class loader.- Specified by:
enableBootstrapInjectionin interfaceAgentBuilder- Parameters:
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.- Returns:
- An agent builder with bootstrap class loader class injection enabled.
-
enableUnsafeBootstrapInjection
public AgentBuilder enableUnsafeBootstrapInjection()
Description copied from interface:AgentBuilderEnables class injection of auxiliary classes into the bootstrap class loader which relies onsun.misc.Unsafe.- Specified by:
enableUnsafeBootstrapInjectionin interfaceAgentBuilder- Returns:
- An agent builder with bootstrap class loader class injection enabled.
-
disableBootstrapInjection
public AgentBuilder disableBootstrapInjection()
Description copied from interface:AgentBuilderDisables injection of auxiliary classes into the bootstrap class path.- Specified by:
disableBootstrapInjectionin interfaceAgentBuilder- Returns:
- A new instance of this agent builder which does not apply bootstrap class loader injection.
-
enableNativeMethodPrefix
public AgentBuilder enableNativeMethodPrefix(java.lang.String prefix)
Description copied from interface:AgentBuilderEnables 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:
enableNativeMethodPrefixin interfaceAgentBuilder- Parameters:
prefix- The prefix to be used.- Returns:
- A new instance of this agent builder which uses the given native method prefix.
-
disableNativeMethodPrefix
public AgentBuilder disableNativeMethodPrefix()
Description copied from interface:AgentBuilderDisables the use of a native method prefix for instrumented methods.- Specified by:
disableNativeMethodPrefixin interfaceAgentBuilder- Returns:
- A new instance of this agent builder which does not use a native method prefix.
-
disableClassFormatChanges
public AgentBuilder disableClassFormatChanges()
Description copied from interface:AgentBuilderDisables 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.NoOpandAgentBuilder.TypeStrategy.Default.REDEFINE_FROZENas well as configuring the underlyingByteBuddyinstance to use aImplementation.Context.Disabled. Using this strategy also configures Byte Buddy to create frozen instrumented types and discards any explicit configuration.- Specified by:
disableClassFormatChangesin interfaceAgentBuilder- Returns:
- A new instance of this agent builder that does not apply any implicit changes to the received class file.
-
assureReadEdgeTo
public AgentBuilder assureReadEdgeTo(java.lang.instrument.Instrumentation instrumentation, java.lang.Class<?>... type)
Description copied from interface:AgentBuilderAssures 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:
assureReadEdgeToin 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:
AgentBuilder.Listener.ModuleReadEdgeCompleting
-
assureReadEdgeTo
public AgentBuilder assureReadEdgeTo(java.lang.instrument.Instrumentation instrumentation, JavaModule... module)
Description copied from interface:AgentBuilderAssures that all supplied modules are read by the module of any instrumented type.- Specified by:
assureReadEdgeToin 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:
AgentBuilder.Listener.ModuleReadEdgeCompleting
-
assureReadEdgeTo
public AgentBuilder assureReadEdgeTo(java.lang.instrument.Instrumentation instrumentation, java.util.Collection<? extends JavaModule> modules)
Description copied from interface:AgentBuilderAssures that all supplied modules are read by the module of any instrumented type.- Specified by:
assureReadEdgeToin 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:
AgentBuilder.Listener.ModuleReadEdgeCompleting
-
assureReadEdgeFromAndTo
public AgentBuilder assureReadEdgeFromAndTo(java.lang.instrument.Instrumentation instrumentation, java.lang.Class<?>... type)
Description copied from interface:AgentBuilderAssures 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.- Specified by:
assureReadEdgeFromAndToin 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:
AgentBuilder.Listener.ModuleReadEdgeCompleting
-
assureReadEdgeFromAndTo
public AgentBuilder assureReadEdgeFromAndTo(java.lang.instrument.Instrumentation instrumentation, JavaModule... module)
Description copied from interface:AgentBuilderAssures that all supplied modules are read by the module of any instrumented type and vice versa.- Specified by:
assureReadEdgeFromAndToin 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:
AgentBuilder.Listener.ModuleReadEdgeCompleting
-
assureReadEdgeFromAndTo
public AgentBuilder assureReadEdgeFromAndTo(java.lang.instrument.Instrumentation instrumentation, java.util.Collection<? extends JavaModule> modules)
Description copied from interface:AgentBuilderAssures that all supplied modules are read by the module of any instrumented type and vice versa.- Specified by:
assureReadEdgeFromAndToin 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:
AgentBuilder.Listener.ModuleReadEdgeCompleting
-
type
public AgentBuilder.Identified.Narrowable type(ElementMatcher<? super TypeDescription> typeMatcher)
Description copied from interface:AgentBuilderMatches a type being loaded in order to apply the supplied
AgentBuilder.Transformers 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 usingAgentBuilder.type(ElementMatcher, ElementMatcher)instead.- Specified by:
typein interfaceAgentBuilder- Parameters:
typeMatcher- AnElementMatcherthat is applied on the type being loaded that decides if the entailedAgentBuilder.Transformers should be applied for that type.- Returns:
- A definable that represents this agent builder which allows for the definition of one or several
AgentBuilder.Transformers to be applied when the giventypeMatcherindicates a match.
-
type
public AgentBuilder.Identified.Narrowable type(ElementMatcher<? super TypeDescription> typeMatcher, ElementMatcher<? super java.lang.ClassLoader> classLoaderMatcher)
Description copied from interface:AgentBuilderMatches a type being loaded in order to apply the supplied
AgentBuilder.Transformers 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.- Specified by:
typein interfaceAgentBuilder- Parameters:
typeMatcher- AnElementMatcherthat is applied on the type being loaded that decides if the entailedAgentBuilder.Transformers should be applied for that type.classLoaderMatcher- AnElementMatcherthat is applied to theClassLoaderthat 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.Transformers to be applied when both the giventypeMatcherandclassLoaderMatcherindicate a match.
-
type
public AgentBuilder.Identified.Narrowable type(ElementMatcher<? super TypeDescription> typeMatcher, ElementMatcher<? super java.lang.ClassLoader> classLoaderMatcher, ElementMatcher<? super JavaModule> moduleMatcher)
Description copied from interface:AgentBuilderMatches a type being loaded in order to apply the supplied
AgentBuilder.Transformers 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.- Specified by:
typein interfaceAgentBuilder- Parameters:
typeMatcher- AnElementMatcherthat is applied on the type being loaded that decides if the entailedAgentBuilder.Transformers should be applied for that type.classLoaderMatcher- AnElementMatcherthat is applied to theClassLoaderthat 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- AnElementMatcherthat is applied to theJavaModuleof 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.Transformers to be applied when both the giventypeMatcherandclassLoaderMatcherindicate a match.
-
type
public AgentBuilder.Identified.Narrowable type(AgentBuilder.RawMatcher matcher)
Description copied from interface:AgentBuilderMatches a type being loaded in order to apply the supplied
AgentBuilder.Transformers 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.- Specified by:
typein interfaceAgentBuilder- Parameters:
matcher- A matcher that decides if the entailedAgentBuilder.Transformers 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.Transformers to be applied when the givenmatcherindicates a match.
-
ignore
public AgentBuilder.Ignored ignore(ElementMatcher<? super TypeDescription> ignoredTypes)
Description copied from interface:AgentBuilderExcludes any type that is matched by the provided matcher from instrumentation and considers types by all
ClassLoaders. 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:
ignorein interfaceAgentBuilder- Parameters:
ignoredTypes- 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> ignoredTypes, ElementMatcher<? super java.lang.ClassLoader> ignoredClassLoaders)
Description copied from interface:AgentBuilderExcludes 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:
ignorein interfaceAgentBuilder- Parameters:
ignoredTypes- A matcher that identifies types that should not be instrumented.ignoredClassLoaders- 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 java.lang.ClassLoader> classLoaderMatcher, ElementMatcher<? super JavaModule> moduleMatcher)
Description copied from interface:AgentBuilderExcludes 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:
ignorein 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
public AgentBuilder.Ignored ignore(AgentBuilder.RawMatcher rawMatcher)
Description copied from interface:AgentBuilderExcludes 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:
ignorein 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
public java.lang.instrument.ClassFileTransformer makeRaw()
Description copied from interface:AgentBuilderCreates aClassFileTransformerthat implements the configuration of this agent builder. When using a raw class file transformer, theAgentBuilder.InstallationListenercallbacks are not invoked and the setAgentBuilder.RedefinitionStrategyis not applied onto currently loaded classes.- Specified by:
makeRawin interfaceAgentBuilder- Returns:
- A class file transformer that implements the configuration of this agent builder.
-
installOn
public ResettableClassFileTransformer installOn(java.lang.instrument.Instrumentation instrumentation)
Description copied from interface:AgentBuilderCreates and installs a
ClassFileTransformerthat 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'sresetmethods.- Specified by:
installOnin interfaceAgentBuilder- Parameters:
instrumentation- The instrumentation on which this agent builder's configuration is to be installed.- Returns:
- The installed class file transformer.
-
installOnByteBuddyAgent
public ResettableClassFileTransformer installOnByteBuddyAgent()
Description copied from interface:AgentBuilderCreates and installs aClassFileTransformerthat implements the configuration of this agent builder with the Byte Buddy-agent which must be installed prior to calling this method.- Specified by:
installOnByteBuddyAgentin interfaceAgentBuilder- Returns:
- The installed class file transformer.
- See Also:
AgentBuilder.installOn(Instrumentation)
-
-