protected static class AgentBuilder.Default.ExecutingTransformer extends ResettableClassFileTransformer.AbstractBase
ClassFileTransformer
that implements the enclosing agent builder's
configuration.Modifier and Type | Class and Description |
---|---|
protected static interface |
AgentBuilder.Default.ExecutingTransformer.Factory
A factory for creating a
ClassFileTransformer for the current VM. |
protected class |
AgentBuilder.Default.ExecutingTransformer.Java9CapableVmDispatcher
A privileged action for transforming a class on a JVM that supports modules.
|
protected class |
AgentBuilder.Default.ExecutingTransformer.LegacyVmDispatcher
A privileged action for transforming a class on a JVM prior to Java 9.
|
ResettableClassFileTransformer.AbstractBase
Modifier and Type | Field and Description |
---|---|
private java.security.AccessControlContext |
accessControlContext
The access control context to use for loading classes.
|
private AgentBuilder.Default.BootstrapInjectionStrategy |
bootstrapInjectionStrategy
The injection strategy for injecting classes into the bootstrap class loader.
|
private ByteBuddy |
byteBuddy
The Byte Buddy instance to be used.
|
private AgentBuilder.CircularityLock |
circularityLock
A lock that prevents circular class transformations.
|
private AgentBuilder.ClassFileBufferStrategy |
classFileBufferStrategy
The class file buffer strategy to use.
|
private AgentBuilder.DescriptionStrategy |
descriptionStrategy
The description strategy for resolving type descriptions for types.
|
protected static AgentBuilder.Default.ExecutingTransformer.Factory |
FACTORY
A factory for creating a
ClassFileTransformer that supports the features of the current VM. |
private AgentBuilder.FallbackStrategy |
fallbackStrategy
The fallback strategy to use.
|
private AgentBuilder.RawMatcher |
ignoredTypeMatcher
Identifies types that should not be instrumented.
|
private AgentBuilder.InitializationStrategy |
initializationStrategy
The initialization strategy to use for transformed types.
|
private AgentBuilder.InstallationListener |
installationListener
The installation listener to notify.
|
private AgentBuilder.LambdaInstrumentationStrategy |
lambdaInstrumentationStrategy
The lambda instrumentation strategy to use.
|
private AgentBuilder.Listener |
listener
The listener to notify on transformations.
|
private AgentBuilder.LocationStrategy |
locationStrategy
The location strategy to use.
|
private AgentBuilder.Default.NativeMethodStrategy |
nativeMethodStrategy
The native method strategy to apply.
|
private AgentBuilder.PoolStrategy |
poolStrategy
The type locator to use.
|
private AgentBuilder.Default.Transformation |
transformation
The transformation object for handling type transformations.
|
private AgentBuilder.TypeStrategy |
typeStrategy
The definition handler to use.
|
Constructor and Description |
---|
ExecutingTransformer(ByteBuddy byteBuddy,
AgentBuilder.Listener listener,
AgentBuilder.PoolStrategy poolStrategy,
AgentBuilder.TypeStrategy typeStrategy,
AgentBuilder.LocationStrategy locationStrategy,
AgentBuilder.Default.NativeMethodStrategy nativeMethodStrategy,
AgentBuilder.InitializationStrategy initializationStrategy,
AgentBuilder.Default.BootstrapInjectionStrategy bootstrapInjectionStrategy,
AgentBuilder.LambdaInstrumentationStrategy lambdaInstrumentationStrategy,
AgentBuilder.DescriptionStrategy descriptionStrategy,
AgentBuilder.FallbackStrategy fallbackStrategy,
AgentBuilder.ClassFileBufferStrategy classFileBufferStrategy,
AgentBuilder.InstallationListener installationListener,
AgentBuilder.RawMatcher ignoredTypeMatcher,
AgentBuilder.Default.Transformation transformation,
AgentBuilder.CircularityLock circularityLock)
Creates a new class file transformer.
|
Modifier and Type | Method and Description |
---|---|
private byte[] |
doTransform(JavaModule module,
java.lang.ClassLoader classLoader,
java.lang.String typeName,
java.lang.Class<?> classBeingRedefined,
boolean loaded,
java.security.ProtectionDomain protectionDomain,
TypePool typePool,
ClassFileLocator classFileLocator)
Applies a transformation for a class that was captured by this
ClassFileTransformer . |
boolean |
reset(java.lang.instrument.Instrumentation instrumentation,
ResettableClassFileTransformer classFileTransformer,
AgentBuilder.RedefinitionStrategy redefinitionStrategy,
AgentBuilder.RedefinitionStrategy.DiscoveryStrategy redefinitionDiscoveryStrategy,
AgentBuilder.RedefinitionStrategy.BatchAllocator redefinitionBatchAllocator,
AgentBuilder.RedefinitionStrategy.Listener redefinitionListener)
Deregisters this class file transformer and redefines any transformed class to its state without this
class file transformer applied, if the supplied redefinition strategy is enabled.
|
private AgentBuilder.Default.Transformation.Resolution |
resolve(JavaModule module,
java.lang.ClassLoader classLoader,
java.lang.String typeName,
java.lang.Class<?> classBeingRedefined,
boolean loaded,
java.security.ProtectionDomain protectionDomain,
TypePool typePool)
Resolves the transformation and assures it is not ignored.
|
byte[] |
transform(java.lang.ClassLoader classLoader,
java.lang.String internalTypeName,
java.lang.Class<?> classBeingRedefined,
java.security.ProtectionDomain protectionDomain,
byte[] binaryRepresentation) |
private byte[] |
transform(JavaModule module,
java.lang.ClassLoader classLoader,
java.lang.String internalTypeName,
java.lang.Class<?> classBeingRedefined,
java.security.ProtectionDomain protectionDomain,
byte[] binaryRepresentation)
Applies a transformation for a class that was captured by this
ClassFileTransformer . |
protected byte[] |
transform(java.lang.Object rawModule,
java.lang.ClassLoader classLoader,
java.lang.String internalTypeName,
java.lang.Class<?> classBeingRedefined,
java.security.ProtectionDomain protectionDomain,
byte[] binaryRepresentation)
Applies a transformation for a class that was captured by this
ClassFileTransformer . |
protected static final AgentBuilder.Default.ExecutingTransformer.Factory FACTORY
ClassFileTransformer
that supports the features of the current VM.private final ByteBuddy byteBuddy
private final AgentBuilder.PoolStrategy poolStrategy
private final AgentBuilder.TypeStrategy typeStrategy
private final AgentBuilder.Listener listener
private final AgentBuilder.Default.NativeMethodStrategy nativeMethodStrategy
private final AgentBuilder.InitializationStrategy initializationStrategy
private final AgentBuilder.Default.BootstrapInjectionStrategy bootstrapInjectionStrategy
private final AgentBuilder.LambdaInstrumentationStrategy lambdaInstrumentationStrategy
private final AgentBuilder.DescriptionStrategy descriptionStrategy
private final AgentBuilder.LocationStrategy locationStrategy
private final AgentBuilder.FallbackStrategy fallbackStrategy
private final AgentBuilder.ClassFileBufferStrategy classFileBufferStrategy
private final AgentBuilder.InstallationListener installationListener
private final AgentBuilder.RawMatcher ignoredTypeMatcher
private final AgentBuilder.Default.Transformation transformation
private final AgentBuilder.CircularityLock circularityLock
private final java.security.AccessControlContext accessControlContext
public ExecutingTransformer(ByteBuddy byteBuddy, AgentBuilder.Listener listener, AgentBuilder.PoolStrategy poolStrategy, AgentBuilder.TypeStrategy typeStrategy, AgentBuilder.LocationStrategy locationStrategy, AgentBuilder.Default.NativeMethodStrategy nativeMethodStrategy, AgentBuilder.InitializationStrategy initializationStrategy, AgentBuilder.Default.BootstrapInjectionStrategy bootstrapInjectionStrategy, AgentBuilder.LambdaInstrumentationStrategy lambdaInstrumentationStrategy, AgentBuilder.DescriptionStrategy descriptionStrategy, AgentBuilder.FallbackStrategy fallbackStrategy, AgentBuilder.ClassFileBufferStrategy classFileBufferStrategy, AgentBuilder.InstallationListener installationListener, AgentBuilder.RawMatcher ignoredTypeMatcher, AgentBuilder.Default.Transformation transformation, AgentBuilder.CircularityLock circularityLock)
byteBuddy
- The Byte Buddy instance to be used.listener
- The listener to notify on transformations.poolStrategy
- The type locator to use.typeStrategy
- The definition handler to use.locationStrategy
- The location strategy to use.nativeMethodStrategy
- The native method strategy to apply.initializationStrategy
- The initialization strategy to use for transformed types.bootstrapInjectionStrategy
- The injection strategy for injecting classes into the bootstrap class loader.lambdaInstrumentationStrategy
- The lambda instrumentation strategy to use.descriptionStrategy
- The description strategy for resolving type descriptions for types.fallbackStrategy
- The fallback strategy to use.installationListener
- The installation listener to notify.classFileBufferStrategy
- The class file buffer strategy to use.ignoredTypeMatcher
- Identifies types that should not be instrumented.transformation
- The transformation object for handling type transformations.circularityLock
- The circularity lock to use.public byte[] transform(java.lang.ClassLoader classLoader, java.lang.String internalTypeName, java.lang.Class<?> classBeingRedefined, java.security.ProtectionDomain protectionDomain, byte[] binaryRepresentation)
protected byte[] transform(java.lang.Object rawModule, java.lang.ClassLoader classLoader, java.lang.String internalTypeName, java.lang.Class<?> classBeingRedefined, java.security.ProtectionDomain protectionDomain, byte[] binaryRepresentation)
ClassFileTransformer
. Invoking this method
allows to process module information which is available since Java 9.rawModule
- The instrumented class's Java java.lang.Module
.classLoader
- The type's class loader or null
if the type is loaded by the bootstrap loader.internalTypeName
- The internal name of the instrumented class.classBeingRedefined
- The loaded Class
being redefined or null
if no such class exists.protectionDomain
- The instrumented type's protection domain.binaryRepresentation
- The class file of the instrumented class in its current state.private byte[] transform(JavaModule module, java.lang.ClassLoader classLoader, java.lang.String internalTypeName, java.lang.Class<?> classBeingRedefined, java.security.ProtectionDomain protectionDomain, byte[] binaryRepresentation)
ClassFileTransformer
.module
- The instrumented class's Java module in its wrapped form or null
if the current VM does not support modules.classLoader
- The instrumented class's class loader.internalTypeName
- The internal name of the instrumented class.classBeingRedefined
- The loaded Class
being redefined or null
if no such class exists.protectionDomain
- The instrumented type's protection domain.binaryRepresentation
- The class file of the instrumented class in its current state.private byte[] doTransform(JavaModule module, java.lang.ClassLoader classLoader, java.lang.String typeName, java.lang.Class<?> classBeingRedefined, boolean loaded, java.security.ProtectionDomain protectionDomain, TypePool typePool, ClassFileLocator classFileLocator)
ClassFileTransformer
.module
- The instrumented class's Java module in its wrapped form or null
if the current VM does not support modules.classLoader
- The instrumented class's class loader.typeName
- The binary name of the instrumented class.classBeingRedefined
- The loaded Class
being redefined or null
if no such class exists.loaded
- true
if the instrumented type is loaded.protectionDomain
- The instrumented type's protection domain.typePool
- The type pool to use.classFileLocator
- The class file locator to use.private AgentBuilder.Default.Transformation.Resolution resolve(JavaModule module, java.lang.ClassLoader classLoader, java.lang.String typeName, java.lang.Class<?> classBeingRedefined, boolean loaded, java.security.ProtectionDomain protectionDomain, TypePool typePool)
module
- The instrumented class's Java module in its wrapped form or null
if the current VM does not support modules.classLoader
- The instrumented class's class loader.typeName
- The binary name of the instrumented class.classBeingRedefined
- The loaded Class
being redefined or null
if no such class exists.loaded
- true
if the instrumented type is loaded.protectionDomain
- The instrumented type's protection domain.typePool
- The type pool to use.public boolean reset(java.lang.instrument.Instrumentation instrumentation, ResettableClassFileTransformer classFileTransformer, AgentBuilder.RedefinitionStrategy redefinitionStrategy, AgentBuilder.RedefinitionStrategy.DiscoveryStrategy redefinitionDiscoveryStrategy, AgentBuilder.RedefinitionStrategy.BatchAllocator redefinitionBatchAllocator, AgentBuilder.RedefinitionStrategy.Listener redefinitionListener)
Deregisters this class file transformer and redefines any transformed class to its state without this
class file transformer applied, if the supplied redefinition strategy is enabled. If it is not enabled,
only the AgentBuilder.InstallationListener
is informed about the
resetting without undoing any code changes.
Note: A reset class file transformer should not be reinstalled. Instead, the AgentBuilder
which built the transformer should be asked to install a new transformer.
Important: Most JVMs do not support changes of a class's structure after a class was already
loaded. Therefore, it is typically required that this class file transformer was built while enabling
AgentBuilder.disableClassFormatChanges()
.
instrumentation
- The instrumentation instance from which to deregister the transformer.classFileTransformer
- The actual class file transformer to deregister which might be this
instance or any wrapper.redefinitionStrategy
- The redefinition to apply.redefinitionDiscoveryStrategy
- The discovery strategy for the types to reset.redefinitionBatchAllocator
- The batch allocator to use.redefinitionListener
- The redefinition listener to apply.true
if a reset was applied and this transformer was not previously removed.