Package net.bytebuddy.agent.builder
Class AgentBuilder.RedefinitionStrategy.Collector
java.lang.Object
net.bytebuddy.agent.builder.AgentBuilder.RedefinitionStrategy.Collector
- Direct Known Subclasses:
AgentBuilder.RedefinitionStrategy.Collector.ForRedefinition
,AgentBuilder.RedefinitionStrategy.Collector.ForRetransformation
- Enclosing class:
- AgentBuilder.RedefinitionStrategy
A collector is responsible for collecting classes that are to be considered for modification.
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionprotected static class
A collector that applies a redefinition of already loaded classes.protected static class
A collector that applies a retransformation of already loaded classes.protected static class
An iterator that allows prepending of iterables to be applied previous to another iterator. -
Field Summary
FieldsModifier and TypeFieldDescriptionprotected final AgentBuilder.CircularityLock
The circularity lock to use.private final AgentBuilder.DescriptionStrategy
The description strategy for resolving type descriptions for types.private final AgentBuilder.FallbackStrategy
The fallback strategy to apply.protected final AgentBuilder.Listener
The listener to notify on transformations.protected final AgentBuilder.LocationStrategy
The location strategy to use.private final AgentBuilder.RawMatcher
The matcher to identify what types to redefine.private final AgentBuilder.PoolStrategy
The pool strategy to use.All types that were collected for redefinition. -
Constructor Summary
ConstructorsModifierConstructorDescriptionprotected
Collector
(AgentBuilder.RawMatcher matcher, AgentBuilder.PoolStrategy poolStrategy, AgentBuilder.LocationStrategy locationStrategy, AgentBuilder.DescriptionStrategy descriptionStrategy, AgentBuilder.Listener listener, AgentBuilder.FallbackStrategy fallbackStrategy, AgentBuilder.CircularityLock circularityLock) Creates a new collector. -
Method Summary
Modifier and TypeMethodDescriptionprotected int
apply
(Instrumentation instrumentation, AgentBuilder.RedefinitionStrategy.BatchAllocator redefinitionBatchAllocator, AgentBuilder.RedefinitionStrategy.Listener redefinitionListener, int batch) Applies all types that this collector collected.protected void
Considers a loaded class for collection.protected abstract void
doApply
(Instrumentation instrumentation, List<Class<?>> types) Applies this collector.private void
doConsider
(AgentBuilder.RawMatcher matcher, AgentBuilder.Listener listener, TypeDescription typeDescription, Class<?> type, Class<?> classBeingRedefined, JavaModule module, boolean modifiable) Does consider the retransformation or redefinition of a loaded type.
-
Field Details
-
matcher
The matcher to identify what types to redefine. -
poolStrategy
The pool strategy to use. -
locationStrategy
The location strategy to use. -
descriptionStrategy
The description strategy for resolving type descriptions for types. -
listener
The listener to notify on transformations. -
fallbackStrategy
The fallback strategy to apply. -
circularityLock
The circularity lock to use. -
types
All types that were collected for redefinition.
-
-
Constructor Details
-
Collector
protected Collector(AgentBuilder.RawMatcher matcher, AgentBuilder.PoolStrategy poolStrategy, AgentBuilder.LocationStrategy locationStrategy, AgentBuilder.DescriptionStrategy descriptionStrategy, AgentBuilder.Listener listener, AgentBuilder.FallbackStrategy fallbackStrategy, AgentBuilder.CircularityLock circularityLock) Creates a new collector.- Parameters:
matcher
- The matcher to identify what types to redefine.poolStrategy
- The pool strategy to use.locationStrategy
- The location strategy to use.descriptionStrategy
- The description strategy for resolving type descriptions for types.listener
- The listener to notify on transformations.fallbackStrategy
- The fallback strategy to apply.circularityLock
- The circularity lock to use.
-
-
Method Details
-
consider
Considers a loaded class for collection.- Parameters:
type
- The loaded type being considered.modifiable
-true
if the considered type is considered modifiable.
-
doConsider
private void doConsider(AgentBuilder.RawMatcher matcher, AgentBuilder.Listener listener, TypeDescription typeDescription, Class<?> type, @MaybeNull Class<?> classBeingRedefined, @MaybeNull JavaModule module, boolean modifiable) Does consider the retransformation or redefinition of a loaded type.- Parameters:
matcher
- A type matcher to apply.listener
- The listener to apply during the consideration.typeDescription
- The type description of the type being considered.type
- The loaded type being considered.classBeingRedefined
- The loaded type being considered ornull
if it should be considered non-available.module
- The type's Java module ornull
if the current VM does not support modules.modifiable
-true
if the considered type is considered modifiable.
-
apply
protected int apply(Instrumentation instrumentation, AgentBuilder.RedefinitionStrategy.BatchAllocator redefinitionBatchAllocator, AgentBuilder.RedefinitionStrategy.Listener redefinitionListener, int batch) Applies all types that this collector collected.- Parameters:
instrumentation
- The instrumentation instance to apply changes to.redefinitionBatchAllocator
- The redefinition batch allocator to use.redefinitionListener
- The redefinition listener to use.batch
- The next batch's index.- Returns:
- The next batch's index after this application.
-
doApply
protected abstract void doApply(Instrumentation instrumentation, List<Class<?>> types) throws UnmodifiableClassException, ClassNotFoundException Applies this collector.- Parameters:
instrumentation
- The instrumentation instance to apply the transformation for.types
- The types of the current patch to transform.- Throws:
UnmodifiableClassException
- If a class is not modifiable.ClassNotFoundException
- If a class could not be found.
-