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
.-
Interface Summary Interface Description AgentBuilder An agent builder provides a convenience API for defining a Java agent.AgentBuilder.CircularityLock A circularity lock is responsible for preventing that aClassFileLocator
is used recursively.AgentBuilder.ClassFileBufferStrategy This strategy determines how the provided class file buffer is used.AgentBuilder.Default.Dispatcher A dispatcher for interacting with the instrumentation API.AgentBuilder.Default.ExecutingTransformer.Factory A factory for creating aClassFileTransformer
for the current VM.AgentBuilder.Default.NativeMethodStrategy A strategy for determining if a native method name prefix should be used when rebasing methods.AgentBuilder.DescriptionStrategy A description strategy is responsible for resolving aTypeDescription
when transforming or retransforming/-defining a type.AgentBuilder.FallbackStrategy A fallback strategy allows to reattempt a transformation or a consideration for redefinition/retransformation in case an exception occurs.AgentBuilder.Identified Describes anAgentBuilder
which was handed a matcher for identifying types to instrumented in order to supply one or severalAgentBuilder.Transformer
s.AgentBuilder.Identified.Extendable This interface is used to allow for optionally providing severalAgentBuilder.Transformer
to applied when a matcher identifies a type to be instrumented.AgentBuilder.Identified.Narrowable Allows to specify a type matcher for a type to instrument.AgentBuilder.Ignored Allows to further specify ignored types.AgentBuilder.InitializationStrategy An initialization strategy which determines the handling ofLoadedTypeInitializer
s and the loading of auxiliary types.AgentBuilder.InitializationStrategy.Dispatcher A dispatcher for changing a class file to adapt a self-initialization strategy.AgentBuilder.InjectionStrategy A strategy for injecting auxiliary types into a class loader.AgentBuilder.InstallationListener A listener that is notified during the installation and the resetting of a class file transformer.AgentBuilder.Listener A listener that is informed about events that occur during an instrumentation process.AgentBuilder.LocationStrategy A strategy for creating aClassFileLocator
when instrumenting a type.AgentBuilder.Matchable<T extends AgentBuilder.Matchable<T>> An abstraction for extending a matcher.AgentBuilder.PoolStrategy A type locator allows to specify howTypeDescription
s are resolved by anAgentBuilder
.AgentBuilder.RawMatcher A matcher that allows to determine if aAgentBuilder.Transformer
should be applied during the execution of aClassFileTransformer
that was generated by anAgentBuilder
.AgentBuilder.RedefinitionListenable An agent builder configuration that allows the registration of listeners to the redefinition process.AgentBuilder.RedefinitionListenable.WithImplicitDiscoveryStrategy An agent builder configuration strategy that allows the definition of a discovery strategy.AgentBuilder.RedefinitionListenable.WithoutBatchStrategy An agent builder configuration that allows the configuration of a batching strategy.AgentBuilder.RedefinitionStrategy.BatchAllocator A batch allocator which is responsible for applying a redefinition in a batches.AgentBuilder.RedefinitionStrategy.DiscoveryStrategy A strategy for discovering types to redefine.AgentBuilder.RedefinitionStrategy.Dispatcher A dispatcher for interacting with the instrumentation API.AgentBuilder.RedefinitionStrategy.Listener A listener to be applied during a redefinition.AgentBuilder.RedefinitionStrategy.ResubmissionScheduler A resubmission scheduler is responsible for scheduling a job that is resubmitting unloaded types that failed during retransformation.AgentBuilder.RedefinitionStrategy.ResubmissionScheduler.Cancelable A cancelable allows to discontinue a resubmission job.AgentBuilder.RedefinitionStrategy.ResubmissionStrategy A resubmission strategy is responsible for enabling resubmission of types that failed to resubmit.AgentBuilder.Transformer A transformer allows to apply modifications to aDynamicType
.AgentBuilder.TransformerDecorator A decorator that allows to change the class file transformer that is registered.AgentBuilder.TypeStrategy A type strategy is responsible for creating a type builder for a type that is being instrumented.ResettableClassFileTransformer A class file transformer that can reset its transformation. -
Class Summary Class Description AgentBuilder.CircularityLock.Default A default implementation of a circularity lock.AgentBuilder.CircularityLock.Global A circularity lock that holds a global monitor and does not permit concurrent access.AgentBuilder.Default The default implementation of anAgentBuilder
.AgentBuilder.Default.Dispatcher.ForJava6CapableVm A dispatcher for a Java 6 capable VM.AgentBuilder.Default.ExecutingTransformer AClassFileTransformer
that implements the enclosing agent builder's configuration.AgentBuilder.Default.ExecutingTransformer.Factory.ForJava9CapableVm 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.AgentBuilder.Default.NativeMethodStrategy.ForPrefix A native method strategy that prefixes method names with a fixed value for supporting rebasing of native methods.AgentBuilder.Default.Redefining An implementation of a default agent builder that allows for refinement of the redefinition strategy.AgentBuilder.Default.Transformation A transformation to apply.AgentBuilder.Default.Transformation.DifferentialMatcher A matcher that considers the differential of two transformers' transformations.AgentBuilder.Default.Transformation.SimpleMatcher A matcher that matches any type that is touched by a transformer without being ignored.AgentBuilder.Default.Transformation.TransformerIterator An iterator over a list of transformations that match a raw matcher specification.AgentBuilder.DescriptionStrategy.SuperTypeLoading 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.AgentBuilder.DescriptionStrategy.SuperTypeLoading.Asynchronous 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.AgentBuilder.DescriptionStrategy.SuperTypeLoading.Asynchronous.ThreadSwitchingClassLoadingDelegate A class loading delegate that delegates loading of the super type to another thread.AgentBuilder.DescriptionStrategy.SuperTypeLoading.Asynchronous.ThreadSwitchingClassLoadingDelegate.NotifyingClassLoadingAction A class loading action that notifies the class loader's lock after the type was loaded.AgentBuilder.DescriptionStrategy.SuperTypeLoading.Asynchronous.ThreadSwitchingClassLoadingDelegate.SimpleClassLoadingAction A class loading action that simply loads a type.AgentBuilder.DescriptionStrategy.SuperTypeLoading.UnlockingClassLoadingDelegate A class loading delegate that unlocks the circularity lock during class loading.AgentBuilder.FallbackStrategy.ByThrowableType A fallback strategy that discriminates by the type of theThrowable
that triggered a request.AgentBuilder.InitializationStrategy.SelfInjection 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.AgentBuilder.InitializationStrategy.SelfInjection.Dispatcher A dispatcher for a self-initialization strategy.AgentBuilder.InitializationStrategy.SelfInjection.Dispatcher.InjectingInitializer A type initializer that injects all auxiliary types of the instrumented type.AgentBuilder.InitializationStrategy.SelfInjection.Eager A form of self-injection where any auxiliary type is loaded eagerly.AgentBuilder.InitializationStrategy.SelfInjection.Eager.Dispatcher A dispatcher for theAgentBuilder.InitializationStrategy.SelfInjection.Eager
strategy.AgentBuilder.InitializationStrategy.SelfInjection.Lazy A form of self-injection where any auxiliary type is loaded lazily.AgentBuilder.InitializationStrategy.SelfInjection.Lazy.Dispatcher A dispatcher for theAgentBuilder.InitializationStrategy.SelfInjection.Lazy
strategy.AgentBuilder.InitializationStrategy.SelfInjection.Split 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.AgentBuilder.InitializationStrategy.SelfInjection.Split.Dispatcher A dispatcher for theAgentBuilder.InitializationStrategy.SelfInjection.Split
strategy.AgentBuilder.InjectionStrategy.UsingInstrumentation An injection strategy that uses bootstrap injection using anInstrumentation
instance.AgentBuilder.InjectionStrategy.UsingUnsafe.OfFactory An injection strategy that uses a factory for creating an unsafe injector.AgentBuilder.InstallationListener.Adapter An adapter implementation for an installation listener that serves as a convenience.AgentBuilder.InstallationListener.Compound A compound installation listener.AgentBuilder.InstallationListener.StreamWriting This installation listener prints the status of any installation to aPrintStream
.AgentBuilder.LambdaInstrumentationStrategy.LambdaInstanceFactory A factory that creates instances that represent lambda expressions.AgentBuilder.LambdaInstrumentationStrategy.LambdaInstanceFactory.BridgeMethodImplementation Implements an explicit bridge method for a lambda expression.AgentBuilder.LambdaInstrumentationStrategy.LambdaInstanceFactory.BridgeMethodImplementation.Appender An appender for implementing a bridge method for a lambda expression.AgentBuilder.LambdaInstrumentationStrategy.LambdaInstanceFactory.ConstructorImplementation.Appender An appender to implement the executing transformer.AgentBuilder.LambdaInstrumentationStrategy.LambdaInstanceFactory.FactoryImplementation.Appender An appender for a lambda expression factory.AgentBuilder.LambdaInstrumentationStrategy.LambdaInstanceFactory.LambdaMethodImplementation Implements a lambda expression's functional method.AgentBuilder.LambdaInstrumentationStrategy.LambdaInstanceFactory.LambdaMethodImplementation.Appender An appender for a lambda expression's functional method.AgentBuilder.LambdaInstrumentationStrategy.LambdaInstanceFactory.SerializationImplementation Implements thewriteReplace
method for serializable lambda expressions.AgentBuilder.Listener.Adapter An adapter for a listener where all methods are implemented as non-operational.AgentBuilder.Listener.Compound A compound listener that allows to group several listeners in one instance.AgentBuilder.Listener.Filtering A listener that filters types with a given name from being logged.AgentBuilder.Listener.ModuleReadEdgeCompleting 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.AgentBuilder.Listener.StreamWriting A listener that writes events to aPrintStream
.AgentBuilder.Listener.WithErrorsOnly A listener that only delegates events if they are failed transformations.AgentBuilder.Listener.WithTransformationsOnly A listener that only delegates events if they are successful or failed transformations.AgentBuilder.LocationStrategy.Compound A compound location strategy that applies a list of location strategies.AgentBuilder.LocationStrategy.Simple A simple location strategy that queries a given class file locator.AgentBuilder.Matchable.AbstractBase<S extends AgentBuilder.Matchable<S>> An abstract base implementation of a matchable.AgentBuilder.PoolStrategy.WithTypePoolCache A type locator that uses type pools but allows for the configuration of a custom cache provider by class loader.AgentBuilder.PoolStrategy.WithTypePoolCache.Simple An implementation of a type locatorAgentBuilder.PoolStrategy.WithTypePoolCache
(note documentation of the linked class) that is based on aConcurrentMap
.AgentBuilder.RawMatcher.Conjunction A conjunction of two raw matchers.AgentBuilder.RawMatcher.Disjunction A disjunction of two raw matchers.AgentBuilder.RawMatcher.ForElementMatchers A raw matcher implementation that checks aTypeDescription
and itsClassLoader
against two suitable matchers in order to determine if the matched type should be instrumented.AgentBuilder.RawMatcher.Inversion A raw matcher that inverts a raw matcher's result.AgentBuilder.RedefinitionStrategy.BatchAllocator.ForFixedSize A batch allocator that creates chunks with a fixed size as batch jobs.AgentBuilder.RedefinitionStrategy.BatchAllocator.ForMatchedGrouping A batch allocator that groups all batches by discriminating types using a type matcher.AgentBuilder.RedefinitionStrategy.BatchAllocator.Partitioning A partitioning batch allocator that splits types for redefinition into a fixed amount of parts.AgentBuilder.RedefinitionStrategy.BatchAllocator.Slicing A slicing batch allocator that assures that any batch is within a certain size range.AgentBuilder.RedefinitionStrategy.BatchAllocator.Slicing.SlicingIterable An iterable that slices batches into parts of a minimum and maximum size.AgentBuilder.RedefinitionStrategy.BatchAllocator.Slicing.SlicingIterable.SlicingIterator An iterator that slices batches into parts of a minimum and maximum size.AgentBuilder.RedefinitionStrategy.Collector A collector is responsible for collecting classes that are to be considered for modification.AgentBuilder.RedefinitionStrategy.Collector.ForRedefinition A collector that applies a redefinition of already loaded classes.AgentBuilder.RedefinitionStrategy.Collector.ForRetransformation A collector that applies a retransformation of already loaded classes.AgentBuilder.RedefinitionStrategy.Collector.PrependableIterator An iterator that allows prepending of iterables to be applied previous to another iterator.AgentBuilder.RedefinitionStrategy.DiscoveryStrategy.Explicit An explicit discovery strategy that only attempts the redefinition of specific types.AgentBuilder.RedefinitionStrategy.DiscoveryStrategy.Reiterating.ReiteratingIterable An iterable that returns any loaded types and checks if any additional types were loaded during the last instrumentation.AgentBuilder.RedefinitionStrategy.DiscoveryStrategy.Reiterating.ReiteratingIterator A reiterating iterator that considers types that were loaded during an instrumentation.AgentBuilder.RedefinitionStrategy.Dispatcher.ForJava6CapableVm A dispatcher for a Java 6 capable VM.AgentBuilder.RedefinitionStrategy.Listener.Adapter A listener adapter that offers non-operational implementations of all listener methods.AgentBuilder.RedefinitionStrategy.Listener.BatchReallocator A batch reallocator allows to split up a failed retransformation into additional batches which are reenqueed to the current retransformation process.AgentBuilder.RedefinitionStrategy.Listener.Compound A compound listener that delegates events to several listeners.AgentBuilder.RedefinitionStrategy.Listener.Compound.CompoundIterable A compound iterable.AgentBuilder.RedefinitionStrategy.Listener.Compound.CompoundIterable.CompoundIterator A compound iterator that combines several iterables.AgentBuilder.RedefinitionStrategy.Listener.Pausing A listener that invokesThread.sleep(long)
prior to every batch but the first batch.AgentBuilder.RedefinitionStrategy.Listener.StreamWriting A listener that writes events to aPrintStream
.AgentBuilder.RedefinitionStrategy.ResubmissionScheduler.AtFixedRate A resubmission scheduler that schedules jobs at a fixed rate.AgentBuilder.RedefinitionStrategy.ResubmissionScheduler.Cancelable.ForFuture A cancelable for aFuture
.AgentBuilder.RedefinitionStrategy.ResubmissionScheduler.WithFixedDelay A resubmission scheduler that schedules jobs with a fixed delay.AgentBuilder.RedefinitionStrategy.ResubmissionStrategy.Enabled An enabled resubmission strategy.AgentBuilder.RedefinitionStrategy.ResubmissionStrategy.Enabled.LookupKey A key for a class loader that can only be used for looking up a preexisting value but avoids reference management.AgentBuilder.RedefinitionStrategy.ResubmissionStrategy.Enabled.ResubmissionInstallationListener A job that resubmits any matched type that previously failed during transformation.AgentBuilder.RedefinitionStrategy.ResubmissionStrategy.Enabled.ResubmissionListener A listener that registers types for resubmission that failed during transformations.AgentBuilder.RedefinitionStrategy.ResubmissionStrategy.Enabled.ResubmissionListener.ConcurrentHashSet<T> A set projection for aConcurrentHashMap
.AgentBuilder.RedefinitionStrategy.ResubmissionStrategy.Enabled.StorageKey A key for a class loader that only weakly references the class loader.AgentBuilder.RedefinitionStrategy.ResubmissionStrategy.Installation Represents an installation of a resubmission strategy.AgentBuilder.Transformer.ForAdvice A transformer for applying anAdvice
where this advice class might reference types of both the agent's and the user's class loader.AgentBuilder.Transformer.ForAdvice.Entry An entry for an advice to apply.AgentBuilder.Transformer.ForAdvice.Entry.ForSplitAdvice An entry for an advice class where both entry and exit advice methods are declared by the different classes.AgentBuilder.Transformer.ForAdvice.Entry.ForUnifiedAdvice An entry for an advice class where both the (optional) entry and exit advice methods are declared by the same class.AgentBuilder.Transformer.ForBuildPlugin A transformer that applies a buildPlugin
.AgentBuilder.TransformerDecorator.Compound A compound transformer decorator.AgentBuilder.TypeStrategy.ForBuildEntryPoint A type strategy that applies a buildEntryPoint
.LambdaFactory This class serves as a dispatcher for creating lambda expression objects when Byte Buddy is configured to instrument thejava.lang.invoke.LambdaMetafactory
.ResettableClassFileTransformer.AbstractBase An abstract base implementation of aResettableClassFileTransformer
.ResettableClassFileTransformer.WithDelegation Implements a resettable class file transformer that allows for the delegation of a transformation. -
Enum Summary Enum Description AgentBuilder.CircularityLock.Inactive An inactive circularity lock which is always acquirable.AgentBuilder.ClassFileBufferStrategy.Default An implementation of default class file buffer strategy.AgentBuilder.Default.Dispatcher.CreationAction An action for creating a dispatcher.AgentBuilder.Default.Dispatcher.ForLegacyVm A dispatcher for a legacy VM.AgentBuilder.Default.ExecutingTransformer.Factory.CreationAction An action to create an implementation ofAgentBuilder.Default.ExecutingTransformer
that support Java 9 modules.AgentBuilder.Default.ExecutingTransformer.Factory.ForLegacyVm A factory for aClassFileTransformer
on a VM that does not support thejava.lang.Module
API.AgentBuilder.Default.NativeMethodStrategy.Disabled A native method strategy that suffixes method names with a random suffix and disables native method rebasement.AgentBuilder.DescriptionStrategy.Default Default implementations of aAgentBuilder.DescriptionStrategy
.AgentBuilder.FallbackStrategy.Simple A simple fallback strategy that either always reattempts a transformation or never does so.AgentBuilder.InitializationStrategy.Minimal An initialization strategy that loads auxiliary types before loading the instrumented type.AgentBuilder.InitializationStrategy.NoOp A non-initializing initialization strategy.AgentBuilder.InjectionStrategy.Disabled An injection strategy that does not permit class injection.AgentBuilder.InjectionStrategy.UsingReflection An injection strategy that uses Java reflection.AgentBuilder.InjectionStrategy.UsingUnsafe An injection strategy that usessun.misc.Unsafe
to inject classes.AgentBuilder.InstallationListener.ErrorSuppressing A listener that suppresses any installation error.AgentBuilder.InstallationListener.NoOp A non-operational listener that does not do anything.AgentBuilder.LambdaInstrumentationStrategy Implements the instrumentation of theLambdaMetafactory
if this feature is enabled.AgentBuilder.LambdaInstrumentationStrategy.AlternativeMetaFactoryRedirection Implements the alternative lambda meta factory.AgentBuilder.LambdaInstrumentationStrategy.LambdaInstanceFactory.ConstructorImplementation Implements a lambda class's executing transformer.AgentBuilder.LambdaInstrumentationStrategy.LambdaInstanceFactory.FactoryImplementation An implementation of a instance factory for a lambda expression's class.AgentBuilder.LambdaInstrumentationStrategy.MetaFactoryRedirection Implements the regular lambda meta factory.AgentBuilder.Listener.NoOp A no-op implementation of aAgentBuilder.Listener
.AgentBuilder.LocationStrategy.ForClassLoader A location strategy that locates class files by querying an instrumented type'sClassLoader
.AgentBuilder.LocationStrategy.NoOp A location strategy that never locates any byte code.AgentBuilder.PoolStrategy.ClassLoading A type locator that attempts loading a type if it cannot be located by the underlying lazy type pool.AgentBuilder.PoolStrategy.Default A default type locator that resolves types only if any property that is not the type's name is requested.AgentBuilder.PoolStrategy.Eager A type locator that resolves all type descriptions eagerly.AgentBuilder.RawMatcher.ForLoadState A raw matcher indicating the state of a type's class loading.AgentBuilder.RawMatcher.ForResolvableTypes Only matches loaded types that can be fully resolved.AgentBuilder.RawMatcher.Trivial A matcher that always or never matches a type.AgentBuilder.RedefinitionStrategy A redefinition strategy regulates how already loaded classes are modified by a built agent.AgentBuilder.RedefinitionStrategy.BatchAllocator.ForTotal A batch allocator that includes all types in a single batch.AgentBuilder.RedefinitionStrategy.DiscoveryStrategy.Reiterating A discovery strategy that considers all loaded types supplied byInstrumentation.getAllLoadedClasses()
.AgentBuilder.RedefinitionStrategy.DiscoveryStrategy.SinglePass A discovery strategy that considers all loaded types supplied byInstrumentation.getAllLoadedClasses()
.AgentBuilder.RedefinitionStrategy.Dispatcher.CreationAction An action for creating a dispatcher.AgentBuilder.RedefinitionStrategy.Dispatcher.ForLegacyVm A dispatcher for a legacy VM.AgentBuilder.RedefinitionStrategy.Listener.ErrorEscalating A listener that halts a retransformation process upon an exception.AgentBuilder.RedefinitionStrategy.Listener.NoOp A non-operational listener.AgentBuilder.RedefinitionStrategy.Listener.Yielding A listener that invokesThread.yield()
prior to every batch but the first batch.AgentBuilder.RedefinitionStrategy.ResubmissionScheduler.Cancelable.NoOp A non-operational cancelable.AgentBuilder.RedefinitionStrategy.ResubmissionScheduler.NoOp A resubmission scheduler that does not apply any scheduling.AgentBuilder.RedefinitionStrategy.ResubmissionStrategy.Disabled A disabled resubmission strategy.AgentBuilder.TransformerDecorator.NoOp A transformer decorator that retains the original transformer.AgentBuilder.TypeStrategy.Default Default implementations of type strategies.