Top Description Inners Fields Constructors Methods
org.easymock.bytebuddy.dynamic.loading

public Class ClassReloadingStrategy

extends Object
implements ClassLoadingStrategy<ClassLoader>
Class Inheritance
All Implemented Interfaces
org.easymock.bytebuddy.dynamic.loading.ClassLoadingStrategy
Annotations
@Enhance
Imports
org.easymock.bytebuddy.agent.builder.AgentBuilder, org.easymock.bytebuddy.build.AccessControllerPlugin, .HashCodeAndEqualsPlugin, org.easymock.bytebuddy.description.type.TypeDescription, org.easymock.bytebuddy.dynamic.ClassFileLocator, org.easymock.bytebuddy.utility.JavaModule, org.easymock.bytebuddy.utility.dispatcher.JavaDispatcher, org.easymock.bytebuddy.utility.nullability.AlwaysNull, .MaybeNull, java.io.File, .IOException, java.lang.instrument.ClassDefinition, .ClassFileTransformer, .Instrumentation, .UnmodifiableClassException, java.security.PrivilegedAction, .ProtectionDomain, java.util.*, java.util.concurrent.ConcurrentHashMap

The class reloading strategy allows to redefine loaded java.lang.Classes. Note that this strategy will always attempt to load an existing class prior to its redefinition, even if this class is not yet loaded.

Note

In order to redefine any type, neither its name or its modifiers must be changed. Furthermore, no fields or methods must be removed or added. This makes this strategy generally incompatible to applying it to a rebased class definition as by org.easymock.bytebuddy.ByteBuddy#rebase(Class) which copies the original method implementations to additional methods. Furthermore, even the org.easymock.bytebuddy.ByteBuddy#redefine(Class) adds a method if the original class contains an explicit class initializer. For these reasons, it is not recommended to use this ClassLoadingStrategy with arbitrary classes.

Nested and Inner Type Summary

Modifier and TypeClass and Description
protected static interface
ClassReloadingStrategy.BootstrapInjection

A strategy to apply for injecting classes into the bootstrap class loader.

protected static interface
ClassReloadingStrategy.Dispatcher

A dispatcher to interact with the instrumentation API.

public static enum
ClassReloadingStrategy.Strategy

A strategy which performs the actual redefinition of a java.lang.Class.

Field Summary

Modifier and TypeField and Description
private final ClassReloadingStrategy.BootstrapInjection
bootstrapInjection

The strategy to apply for injecting classes into the bootstrap class loader.

protected static final ClassReloadingStrategy.Dispatcher
DISPATCHER

A dispatcher to use with some methods of the Instrumentation API.

private final Instrumentation
instrumentation

This instance's instrumentation.

private final Map<String, Class<?>>
preregisteredTypes

The preregistered types of this instance.

private final ClassReloadingStrategy.Strategy
strategy

An strategy which performs the actual redefinition of a java.lang.Class.

Constructor Summary

AccessConstructor and Description
public
ClassReloadingStrategy(Instrumentation
The instrumentation to be used by this reloading strategy.
instrumentation
,
ClassReloadingStrategy.Strategy
A strategy which performs the actual redefinition of a java.lang.Class.
strategy
)

Creates a class reloading strategy for the given instrumentation using an explicit transformation strategy which is represented by an Strategy.

protected
ClassReloadingStrategy(Instrumentation
The instrumentation to be used by this reloading strategy.
instrumentation
,
ClassReloadingStrategy.Strategy
An strategy which performs the actual redefinition of a java.lang.Class.
strategy
,
ClassReloadingStrategy.BootstrapInjection
The bootstrap class loader injection strategy to use.
bootstrapInjection
,
Map<String, Class<?>>
The preregistered types of this instance.
preregisteredTypes
)

Creates a new class reloading strategy.

Method Summary

Modifier and TypeMethod and Description
private static <
The type of the action's resolved value.
T
>
T

Returns:

The action's resolved value.
doPrivileged
(PrivilegedAction<T>
The action to execute from a privileged context.
action
)

A proxy for java.security.AccessController#doPrivileged that is activated if available.

public ClassReloadingStrategy

Returns:

A class reloading strategy with bootstrap injection enabled.
enableBootstrapInjection
(File
The folder to save jar files in that are appended to the bootstrap class path.
folder
)

Enables bootstrap injection for this class reloading strategy.

public static ClassReloadingStrategy

Returns:

A class reloading strategy which uses the Byte Buddy agent's java.lang.instrument.Instrumentation.
fromInstalledAgent
()

Obtains a org.easymock.bytebuddy.dynamic.loading.ClassReloadingStrategy from an installed Byte Buddy agent.

public static ClassReloadingStrategy

Returns:

A class reloading strategy which uses the Byte Buddy agent's java.lang.instrument.Instrumentation.
fromInstalledAgent
(ClassReloadingStrategy.Strategy
The strategy to use.
strategy
)

Obtains a org.easymock.bytebuddy.dynamic.loading.ClassReloadingStrategy from an installed Byte Buddy agent.

public Map<TypeDescription, Class<?>>
load(ClassLoader
The class loader to used for loading the classes.
classLoader
,
Map<TypeDescription, byte[]>
Byte array representations of the types to be loaded mapped by their descriptions, where an iteration order defines an order in which they are supposed to be loaded, if relevant.
types
)

Implements org.easymock.bytebuddy.dynamic.loading.ClassLoadingStrategy.load.

Loads a given collection of classes given their binary representation.
public static ClassReloadingStrategy

Returns:

A suitable class reloading strategy.
of
(Instrumentation
The instrumentation to be used by this reloading strategy.
instrumentation
)

Creates a class reloading strategy for the given instrumentation.

public ClassReloadingStrategy

Returns:

This class reloading strategy with the given types being explicitly available.
preregistered
(Class<?>...
The loaded types that are explicitly available.
type
)

Registers a type to be explicitly available without explicit lookup.

public ClassReloadingStrategy

Returns:

This class reloading strategy.
reset
(Class<?>...
The types to reset.
type
)

Resets all classes to their original definition while using the first type's class loader as a class file locator.

public ClassReloadingStrategy

Returns:

This class reloading strategy.
reset
(ClassFileLocator
The class file locator to use.
classFileLocator
,
Class<?>...
The types to reset.
type
)

Resets all classes to their original definition.

private static Instrumentation

Returns:

The installed instrumentation instance.
resolveByteBuddyAgentInstrumentation
()

Resolves the instrumentation provided by net.bytebuddy.agent.Installer.

Inherited from java.lang.Object:
cloneequalsfinalizegetClasshashCodenotifynotifyAlltoStringwaitwaitwait