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
protected abstract static class AgentBuilder.RedefinitionStrategy.Collector extends java.lang.ObjectA collector is responsible for collecting classes that are to be considered for modification.
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description protected static classAgentBuilder.RedefinitionStrategy.Collector.ForRedefinitionA collector that applies a redefinition of already loaded classes.protected static classAgentBuilder.RedefinitionStrategy.Collector.ForRetransformationA collector that applies a retransformation of already loaded classes.protected static classAgentBuilder.RedefinitionStrategy.Collector.PrependableIteratorAn iterator that allows prepending of iterables to be applied previous to another iterator.
-
Field Summary
Fields Modifier and Type Field Description protected AgentBuilder.CircularityLockcircularityLockThe circularity lock to use.private AgentBuilder.DescriptionStrategydescriptionStrategyThe description strategy for resolving type descriptions for types.private AgentBuilder.FallbackStrategyfallbackStrategyThe fallback strategy to apply.protected AgentBuilder.ListenerlistenerThe listener to notify on transformations.protected AgentBuilder.LocationStrategylocationStrategyThe location strategy to use.private AgentBuilder.RawMatchermatcherThe matcher to identify what types to redefine.private AgentBuilder.PoolStrategypoolStrategyThe pool strategy to use.protected java.util.List<java.lang.Class<?>>typesAll types that were collected for redefinition.
-
Constructor Summary
Constructors Modifier Constructor Description protectedCollector(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
All Methods Instance Methods Abstract Methods Concrete Methods Modifier and Type Method Description protected intapply(java.lang.instrument.Instrumentation instrumentation, AgentBuilder.RedefinitionStrategy.BatchAllocator redefinitionBatchAllocator, AgentBuilder.RedefinitionStrategy.Listener redefinitionListener, int batch)Applies all types that this collector collected.protected voidconsider(java.lang.Class<?> type, boolean modifiable)Considers a loaded class for collection.protected abstract voiddoApply(java.lang.instrument.Instrumentation instrumentation, java.util.List<java.lang.Class<?>> types)Applies this collector.private voiddoConsider(AgentBuilder.RawMatcher matcher, AgentBuilder.Listener listener, TypeDescription typeDescription, java.lang.Class<?> type, java.lang.Class<?> classBeingRedefined, JavaModule module, boolean modifiable)Does consider the retransformation or redefinition of a loaded type.
-
-
-
Field Detail
-
matcher
private final AgentBuilder.RawMatcher matcher
The matcher to identify what types to redefine.
-
poolStrategy
private final AgentBuilder.PoolStrategy poolStrategy
The pool strategy to use.
-
locationStrategy
protected final AgentBuilder.LocationStrategy locationStrategy
The location strategy to use.
-
descriptionStrategy
private final AgentBuilder.DescriptionStrategy descriptionStrategy
The description strategy for resolving type descriptions for types.
-
listener
protected final AgentBuilder.Listener listener
The listener to notify on transformations.
-
fallbackStrategy
private final AgentBuilder.FallbackStrategy fallbackStrategy
The fallback strategy to apply.
-
circularityLock
protected final AgentBuilder.CircularityLock circularityLock
The circularity lock to use.
-
types
protected final java.util.List<java.lang.Class<?>> types
All types that were collected for redefinition.
-
-
Constructor Detail
-
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 Detail
-
consider
protected void consider(java.lang.Class<?> type, boolean modifiable)Considers a loaded class for collection.- Parameters:
type- The loaded type being considered.modifiable-trueif the considered type is considered modifiable.
-
doConsider
private void doConsider(AgentBuilder.RawMatcher matcher, AgentBuilder.Listener listener, TypeDescription typeDescription, java.lang.Class<?> type, @MaybeNull java.lang.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 ornullif it should be considered non-available.module- The type's Java module ornullif the current VM does not support modules.modifiable-trueif the considered type is considered modifiable.
-
apply
protected int apply(java.lang.instrument.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(java.lang.instrument.Instrumentation instrumentation, java.util.List<java.lang.Class<?>> types) throws java.lang.instrument.UnmodifiableClassException, java.lang.ClassNotFoundExceptionApplies this collector.- Parameters:
instrumentation- The instrumentation instance to apply the transformation for.types- The types of the current patch to transform.- Throws:
java.lang.instrument.UnmodifiableClassException- If a class is not modifiable.java.lang.ClassNotFoundException- If a class could not be found.
-
-