Package net.bytebuddy.agent.builder
@ByDefault
package net.bytebuddy.agent.builder
An agent builder is used to easily implement load-time class-transformations using a Java agent. The API
builds on Java's
ClassFileTransformer
and Instrumentation
but offers higher-level APIs in order to allow for the implementation of very readable transformations using
ByteBuddy
.-
ClassDescriptionAn agent builder provides a convenience API for defining a Java agent.A circularity lock is responsible for preventing that a
ClassFileLocator
is used recursively.A default implementation of a circularity lock.A circularity lock that holds a global monitor and does not permit concurrent access.An inactive circularity lock which is always acquirable.A circularity lock that surrounds the locking mechanism with a global lock to prevent that the locking mechanism itself loads classes and causes a circularity issue.A trivial lock that monitors if a class is currently loaded by the current thread.This strategy determines how the provided class file buffer is used.An implementation of default class file buffer strategy.The default implementation of anAgentBuilder
.An abstract implementation of an agent builder that delegates all invocation to another instance.An abstract base implementation of a matchable.A dispatcher for interacting with the instrumentation API.AClassFileTransformer
that implements the enclosing agent builder's configuration.A factory for creating aClassFileTransformer
for the current VM.An action to create an implementation ofAgentBuilder.Default.ExecutingTransformer
that support Java 9 modules.A factory for a class file transformer on a JVM that supports thejava.lang.Module
API to override the newly added method of theClassFileTransformer
to capture an instrumented class's module.A factory for aClassFileTransformer
on a VM that does not support thejava.lang.Module
API.A strategy for determining if a native method name prefix should be used when rebasing methods.A native method strategy that suffixes method names with a random suffix and disables native method rebasement.A native method strategy that prefixes method names with a fixed value for supporting rebasing of native methods.An implementation of a default agent builder that allows for refinement of the redefinition strategy.A transformation to apply.A matcher that considers the differential of two transformers' transformations.A matcher that matches any type that is touched by a transformer without being ignored.An iterator over a list of transformations that match a raw matcher specification.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.An enabled warmup strategy.A dispatcher to interact with aClassFileTransformer
when the module system is active.A non-operational warmup strategy.A description strategy is responsible for resolving aTypeDescription
when transforming or retransforming/-defining a type.Default implementations of aAgentBuilder.DescriptionStrategy
.A description strategy that enforces the loading of any super type of a type description but delegates the actual type description to another description strategy.A description strategy that enforces the loading of any super type of a type description but delegates the actual type description to another description strategy.A class loading delegate that delegates loading of the super type to another thread.A class loading action that notifies the class loader's lock after the type was loaded.A class loading action that simply loads a type.A class loading delegate that unlocks the circularity lock during class loading.A fallback strategy allows to reattempt a transformation or a consideration for redefinition/retransformation in case an exception occurs.A fallback strategy that discriminates by the type of theThrowable
that triggered a request.A simple fallback strategy that either always reattempts a transformation or never does so.Describes anAgentBuilder
which was handed a matcher for identifying types to instrumented in order to supply one or severalAgentBuilder.Transformer
s.This interface is used to allow for optionally providing severalAgentBuilder.Transformer
to applied when a matcher identifies a type to be instrumented.Allows to specify a type matcher for a type to instrument.Allows to further specify ignored types.An initialization strategy which determines the handling ofLoadedTypeInitializer
s and the loading of auxiliary types.A dispatcher for changing a class file to adapt a self-initialization strategy.An initialization strategy that loads auxiliary types before loading the instrumented type.A non-initializing initialization strategy.An initialization strategy that adds a code block to an instrumented type's type initializer which then calls a specific class that is responsible for the explicit initialization.A dispatcher for a self-initialization strategy.A type initializer that injects all auxiliary types of the instrumented type.A form of self-injection where any auxiliary type is loaded eagerly.A dispatcher for theAgentBuilder.InitializationStrategy.SelfInjection.Eager
strategy.A form of self-injection where any auxiliary type is loaded lazily.A dispatcher for theAgentBuilder.InitializationStrategy.SelfInjection.Lazy
strategy.A form of self-injection where auxiliary types that are annotated byAuxiliaryType.SignatureRelevant
of the instrumented type are loaded lazily and any other auxiliary type is loaded eagerly.A dispatcher for theAgentBuilder.InitializationStrategy.SelfInjection.Split
strategy.A strategy for injecting auxiliary types into a class loader.An injection strategy that does not permit class injection.An injection strategy that uses bootstrap injection using anInstrumentation
instance.An injection strategy that uses JNA to inject classes.An injection strategy that uses Java reflection.An injection strategy that usessun.misc.Unsafe
orjdk.internal.misc.Unsafe
to inject classes.An injection strategy that uses a factory for creating an unsafe injector.A listener that is notified during the installation and the resetting of a class file transformer.An adapter implementation for an installation listener that serves as a convenience.A compound installation listener.A listener that suppresses any installation error.A non-operational listener that does not do anything.This installation listener prints the status of any installation to aPrintStream
.Implements the instrumentation of theLambdaMetafactory
if this feature is enabled.A factory that creates instances that represent lambda expressions.Implements an explicit bridge method for a lambda expression.AgentBuilder.LambdaInstrumentationStrategy.LambdaInstanceFactory.BridgeMethodImplementation.AppenderAn appender for implementing a bridge method for a lambda expression.Implements a lambda class's executing transformer.An appender to implement the executing transformer.An implementation of a instance factory for a lambda expression's class.An appender for a lambda expression factory.Implements a lambda expression's functional method.AgentBuilder.LambdaInstrumentationStrategy.LambdaInstanceFactory.LambdaMethodImplementation.AppenderAn appender for a lambda expression's functional method.A dispatcher for a lambda expression's implementation.An invocation that is using a direct call to the target method.An invocation that is using an exact invocation of a method handle.Implements thewriteReplace
method for serializable lambda expressions.A factory for rewriting the JDK'sjava.lang.invoke.LambdaMetafactory
methods for use with Byte Buddy.A loader is responsible for loading a generated class file in the current VM.An implementation that indicates that no loader is available.A loader that uses a method handle lookup object to load a class.A loader that is using unsafe API to load a lambda implementation.A listener that is informed about events that occur during an instrumentation process.An adapter for a listener where all methods are implemented as non-operational.A compound listener that allows to group several listeners in one instance.A listener that filters types with a given name from being logged.A listener that adds read-edges to any module of an instrumented class upon its transformation and opens the class's package to the module.A no-op implementation of aAgentBuilder.Listener
.A listener that writes events to aPrintStream
.A listener that only delegates events if they are failed transformations.A listener that only delegates events if they are successful or failed transformations.A strategy for creating aClassFileLocator
when instrumenting a type.A compound location strategy that applies a list of location strategies.A location strategy that locates class files by querying an instrumented type'sClassLoader
.A location strategy that never locates any byte code.A simple location strategy that queries a given class file locator.AgentBuilder.Matchable<T extends AgentBuilder.Matchable<T>>An abstraction for extending a matcher.Determines how patching aResettableClassFileTransformer
resolves the transformer exchange.A handler to allow for callbacks prior and after registering aClassFileTransformer
.A handler for patching byAgentBuilder.PatchMode.GAP
.A handler for patching byAgentBuilder.PatchMode.OVERLAP
.A handler for patching byAgentBuilder.PatchMode.SUBSTITUTE
.A non-operational handler.A type locator allows to specify howTypeDescription
s are resolved by anAgentBuilder
.A type locator that attempts loading a type if it cannot be located by the underlying lazy type pool.A default type locator that resolves types only if any property that is not the type's name is requested.A type locator that resolves all type descriptions eagerly.A type locator that uses type pools but allows for the configuration of a custom cache provider by class loader.An implementation of a type locatorAgentBuilder.PoolStrategy.WithTypePoolCache
(note documentation of the linked class) that is based on aConcurrentMap
.An action that creates a class loader to mark the bootstrap loader without usingnull
.A matcher that allows to determine if aAgentBuilder.Transformer
should be applied during the execution of aClassFileTransformer
that was generated by anAgentBuilder
.A conjunction of two raw matchers.A disjunction of two raw matchers.A raw matcher implementation that checks aTypeDescription
and itsClassLoader
against two suitable matchers in order to determine if the matched type should be instrumented.A raw matcher indicating the state of a type's class loading.Only matches loaded types that can be fully resolved.A raw matcher that inverts a raw matcher's result.A matcher that always or never matches a type.An agent builder configuration that allows the registration of listeners to the redefinition process.A matcher that determines if types should be resubmitted if it is not yet loaded.A matcher for immediate resubmission that matches both of the supplied delegate matchers.A matcher for immediate resubmission that matches either of the supplied delegate matchers.A matcher for immediate resubmission that uses element matchers for each argument to determine a resubmission.A trivial matcher for immediate resubmission.A matcher that determines if types should be resubmitted if it is not yet loaded and if an exception is raised.A matcher for resubmission upon an error that matches both of the supplied delegate matchers.A matcher for resubmission upon an error that matches either of the supplied delegate matchers.A matcher for resubmission upon error that uses element matchers for each argument to determine a resubmission.A trivial matcher for resubmission upon an exception.An agent builder configuration strategy that allows the definition of a discovery strategy.An agent builder configuration that allows the configuration of a batching strategy.AnAgentBuilder
specification that requires a resubmission specification.A complete but extendable resubmission specification.A redefinition strategy regulates how already loaded classes are modified by a built agent.A batch allocator which is responsible for applying a redefinition in a batches.A batch allocator that creates chunks with a fixed size as batch jobs.A batch allocator that groups all batches by discriminating types using a type matcher.A batch allocator that includes all types in a single batch.A partitioning batch allocator that splits types for redefinition into a fixed amount of parts.A slicing batch allocator that assures that any batch is within a certain size range.An iterable that slices batches into parts of a minimum and maximum size.An iterator that slices batches into parts of a minimum and maximum size.A collector is responsible for collecting classes that are to be considered for modification.A collector that applies a redefinition of already loaded classes.A collector that applies a retransformation of already loaded classes.An iterator that allows prepending of iterables to be applied previous to another iterator.A strategy for discovering types to redefine.An explicit discovery strategy that only attempts the redefinition of specific types.A discovery strategy that considers all loaded types supplied byInstrumentation.getAllLoadedClasses()
.An iterable that returns any loaded types and checks if any additional types were loaded during the last instrumentation.A reiterating iterator that considers types that were loaded during an instrumentation.A discovery strategy that simplifies the application ofAgentBuilder.RedefinitionStrategy.DiscoveryStrategy.Reiterating
by assuming that the loaded classes that are returned byInstrumentation.getAllLoadedClasses()
are always returned in the same order.An iterable that reiterates over an array of loaded classes by the previously observed length.An iterator that reiterates over an array of loaded classes by the previously observed length.A discovery strategy that considers all loaded types supplied byInstrumentation.getAllLoadedClasses()
.A dispatcher for interacting with the instrumentation API.A listener to be applied during a redefinition.A listener adapter that offers non-operational implementations of all listener methods.A batch reallocator allows to split up a failed retransformation into additional batches which are reenqueed to the current retransformation process.A compound listener that delegates events to several listeners.A compound iterable.A compound iterator that combines several iterables.A listener that halts a retransformation process upon an exception.A non-operational listener.A listener that invokesThread.sleep(long)
prior to every batch but the first batch.A listener that writes events to aPrintStream
.A listener that invokesThread.yield()
prior to every batch but the first batch.A resubmission enforcer determines if a non-loaded class should be scheduled for resubmission or be treated upon first load.A resubmission enforcer that does not consider non-loaded classes.A resubmission scheduler is responsible for scheduling a job that is resubmitting unloaded types that failed during retransformation.A resubmission scheduler that schedules jobs at a fixed rate.A cancelable allows to discontinue a resubmission job.A cancelable for aFuture
.A non-operational cancelable.A resubmission scheduler that does not apply any scheduling.A resubmission scheduler that schedules jobs with a fixed delay.A resubmission strategy is responsible for enabling resubmission of types that failed to resubmit.A disabled resubmission strategy.An enabled resubmission strategy.A key for a class loader that can only be used for looking up a preexisting value but avoids reference management.A job that resubmits any matched type that previously failed during transformation.A handler for resubmissions.A set projection for aConcurrentHashMap
.A key for a class loader that only weakly references the class loader.Represents an installation of a resubmission strategy.A transformer allows to apply modifications to aDynamicType
.A transformer for applying anAdvice
where this advice class might reference types of both the agent's and the user's class loader.An entry for an advice to apply.An entry for an advice class where both entry and exit advice methods are declared by the different classes.An entry for an advice class where both the (optional) entry and exit advice methods are declared by the same class.A lazy dynamic type that only loads a class file representation on demand.A transformer that applies a buildPlugin
.A decorator that allows to change the class file transformer that is registered.A compound transformer decorator.Wraps a class file transformer to become substitutable.A transformer decorator that retains the original transformer.A type strategy is responsible for creating a type builder for a type that is being instrumented.Default implementations of type strategies.A type strategy that applies a buildEntryPoint
.This class serves as a dispatcher for creating lambda expression objects when Byte Buddy is configured to instrument thejava.lang.invoke.LambdaMetafactory
.A class file transformer that can reset its transformation.An abstract base implementation of aResettableClassFileTransformer
.AResettableClassFileTransformer
which allows for substitution the actual class file transformer without changes in the order of the transformer chain.Implements a resettable class file transformer that allows for the delegation of a transformation.A standard implementation of a substitutableResettableClassFileTransformer
.A factory for creating a subclass ofResettableClassFileTransformer.WithDelegation.Substitutable
that supports the module system, if available.An action to create a suitable factory.A factory for creating a substitutable class file transformer when the module system is supported.A factory for a substitutable class file transformer when the module system is not supported.