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.Object
A 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 class
AgentBuilder.RedefinitionStrategy.Collector.ForRedefinition
A collector that applies a redefinition of already loaded classes.protected static class
AgentBuilder.RedefinitionStrategy.Collector.ForRetransformation
A collector that applies a retransformation of already loaded classes.protected static class
AgentBuilder.RedefinitionStrategy.Collector.PrependableIterator
An iterator that allows prepending of iterables to be applied previous to another iterator.
-
Field Summary
Fields Modifier and Type Field Description private static java.lang.Class<?>
NO_LOADED_TYPE
A representation for a non-available loaded type.protected java.util.List<java.lang.Class<?>>
types
All types that were collected for redefinition.
-
Constructor Summary
Constructors Modifier Constructor Description protected
Collector()
Creates a new collector.
-
Method Summary
All Methods Instance Methods Abstract Methods Concrete Methods Modifier and Type Method Description protected int
apply(java.lang.instrument.Instrumentation instrumentation, AgentBuilder.CircularityLock circularityLock, AgentBuilder.LocationStrategy locationStrategy, AgentBuilder.Listener listener, AgentBuilder.RedefinitionStrategy.BatchAllocator redefinitionBatchAllocator, AgentBuilder.RedefinitionStrategy.Listener redefinitionListener, int batch)
Applies all types that this collector collected.protected void
consider(AgentBuilder.RawMatcher matcher, AgentBuilder.Listener listener, TypeDescription typeDescription, java.lang.Class<?> type, java.lang.Class<?> classBeingRedefined, JavaModule module, boolean unmodifiable)
Does consider the retransformation or redefinition of a loaded type.protected void
consider(AgentBuilder.RawMatcher matcher, AgentBuilder.Listener listener, TypeDescription typeDescription, java.lang.Class<?> type, JavaModule module)
Does consider the retransformation or redefinition of a loaded type without a loaded type representation.protected abstract void
doApply(java.lang.instrument.Instrumentation instrumentation, AgentBuilder.CircularityLock circularityLock, java.util.List<java.lang.Class<?>> types, AgentBuilder.LocationStrategy locationStrategy, AgentBuilder.Listener listener)
Applies this collector.protected void
include(java.util.List<java.lang.Class<?>> types)
Includes all the supplied types in this collector.
-
-
-
Method Detail
-
consider
protected void consider(AgentBuilder.RawMatcher matcher, AgentBuilder.Listener listener, TypeDescription typeDescription, java.lang.Class<?> type, JavaModule module)
Does consider the retransformation or redefinition of a loaded type without a loaded type representation.- Parameters:
matcher
- The 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.module
- The type's Java module ornull
if the current VM does not support modules.
-
consider
protected void consider(AgentBuilder.RawMatcher matcher, AgentBuilder.Listener listener, TypeDescription typeDescription, java.lang.Class<?> type, java.lang.Class<?> classBeingRedefined, JavaModule module, boolean unmodifiable)
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.unmodifiable
-true
if the current type should be considered unmodifiable.
-
include
protected void include(java.util.List<java.lang.Class<?>> types)
Includes all the supplied types in this collector.- Parameters:
types
- The types to include.
-
apply
protected int apply(java.lang.instrument.Instrumentation instrumentation, AgentBuilder.CircularityLock circularityLock, AgentBuilder.LocationStrategy locationStrategy, AgentBuilder.Listener listener, 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.circularityLock
- The circularity lock to use.locationStrategy
- The location strategy to use.listener
- The listener to use.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, AgentBuilder.CircularityLock circularityLock, java.util.List<java.lang.Class<?>> types, AgentBuilder.LocationStrategy locationStrategy, AgentBuilder.Listener listener) throws java.lang.instrument.UnmodifiableClassException, java.lang.ClassNotFoundException
Applies this collector.- Parameters:
instrumentation
- The instrumentation instance to apply the transformation for.circularityLock
- The circularity lock to use.types
- The types of the current patch to transform.locationStrategy
- The location strategy to use.listener
- the listener to notify.- Throws:
java.lang.instrument.UnmodifiableClassException
- If a class is not modifiable.java.lang.ClassNotFoundException
- If a class could not be found.
-
-