public static enum ClassReloadingStrategy.Strategy extends Enum<ClassReloadingStrategy.Strategy>
Class
.Modifier and Type | Class and Description |
---|---|
protected static class |
ClassReloadingStrategy.Strategy.ClassRedefinitionTransformer
A class file transformer that applies a given
ClassDefinition . |
protected static class |
ClassReloadingStrategy.Strategy.ClassResettingTransformer
A transformer that indicates that a class file should not be transformed.
|
Enum Constant and Description |
---|
REDEFINITION
Redefines a class using
Instrumentation.redefineClasses(java.lang.instrument.ClassDefinition...) . |
RETRANSFORMATION
Redefines a class using
Instrumentation.retransformClasses(Class[]) . |
Modifier and Type | Method and Description |
---|---|
protected abstract void |
apply(Instrumentation instrumentation,
Map<Class<?>,ClassDefinition> classDefinitions)
Applies this strategy for the given arguments.
|
boolean |
isRedefinition()
Returns
true if this strategy represents REDEFINITION . |
abstract void |
reset(Instrumentation instrumentation,
ClassFileLocator classFileLocator,
List<Class<?>> types)
Resets the provided types to their original format.
|
protected abstract ClassReloadingStrategy.Strategy |
validate(Instrumentation instrumentation)
Validates that this strategy supports a given transformation type.
|
static ClassReloadingStrategy.Strategy |
valueOf(String name)
Returns the enum constant of this type with the specified name.
|
static ClassReloadingStrategy.Strategy[] |
values()
Returns an array containing the constants of this enum type, in
the order they are declared.
|
public static final ClassReloadingStrategy.Strategy REDEFINITION
Redefines a class using Instrumentation.redefineClasses(java.lang.instrument.ClassDefinition...)
.
This strategy can be more efficient. However, the redefinition strategy does not allow to reset VM anonymous classes (e.g. classes that represent lambda expressions).
public static final ClassReloadingStrategy.Strategy RETRANSFORMATION
Redefines a class using
Instrumentation.retransformClasses(Class[])
. This requires synchronization on
the ClassReloadingStrategy.instrumentation
object.
This strategy can require more time to be applied but does not struggle to reset VM anonymous classes (e.g. classes that represent lambda expressions).
public static ClassReloadingStrategy.Strategy[] values()
for (ClassReloadingStrategy.Strategy c : ClassReloadingStrategy.Strategy.values()) System.out.println(c);
public static ClassReloadingStrategy.Strategy valueOf(String name)
name
- the name of the enum constant to be returned.IllegalArgumentException
- if this enum type has no constant with the specified nameNullPointerException
- if the argument is nullprotected abstract void apply(Instrumentation instrumentation, Map<Class<?>,ClassDefinition> classDefinitions) throws UnmodifiableClassException, ClassNotFoundException
instrumentation
- The instrumentation to be used for applying the redefinition.classDefinitions
- A mapping of the classes to be redefined to their redefinition.UnmodifiableClassException
- If a class is not modifiable.ClassNotFoundException
- If a class was not found.protected abstract ClassReloadingStrategy.Strategy validate(Instrumentation instrumentation)
instrumentation
- The instrumentation instance being used.public boolean isRedefinition()
true
if this strategy represents REDEFINITION
.true
if this strategy represents REDEFINITION
.public abstract void reset(Instrumentation instrumentation, ClassFileLocator classFileLocator, List<Class<?>> types) throws IOException, UnmodifiableClassException, ClassNotFoundException
instrumentation
- The instrumentation instance to use for class redefinition or retransformation.classFileLocator
- The class file locator to use.types
- The types to reset.IOException
- If an I/O exception occurs.UnmodifiableClassException
- If a class is not modifiable.ClassNotFoundException
- If a class could not be found.Copyright © 2014–2019. All rights reserved.