public interface Instrumentation
premain function
that is called before the main function.| Modifier and Type | Method and Description |
|---|---|
void |
addTransformer(ClassFileTransformer transformer)
Adds a
ClassFileTransformer object
to the instrumentation. |
Class[] |
getAllLoadedClasses()
Get all the classes loaded by the JVM.
|
Class[] |
getInitiatedClasses(ClassLoader loader)
Get all the classes loaded by a given class loader
|
long |
getObjectSize(Object objectToSize)
Get the size of an object.
|
boolean |
isRedefineClassesSupported()
Returns if the current JVM supports class redefinition
|
void |
redefineClasses(ClassDefinition[] definitions)
Redefine classes present in the definitions array, with
the corresponding class files.
|
boolean |
removeTransformer(ClassFileTransformer transformer)
Removes the given transformer from the set of transformers
this Instrumentation object has.
|
void addTransformer(ClassFileTransformer transformer)
ClassFileTransformer object
to the instrumentation. Each time a class is defined
or redefined, the transform method of the
transformer object is called.transformer - the transformer to addNullPointerException - if transformer is nullboolean removeTransformer(ClassFileTransformer transformer)
transformer - the transformer to removeNullPointerException - if transformer is nullboolean isRedefineClassesSupported()
void redefineClasses(ClassDefinition[] definitions) throws ClassNotFoundException, UnmodifiableClassException
definitions - an array of classes to redefineClassNotFoundException - if a class cannot be foundUnmodifiableClassException - if a class cannot be modifiedUnsupportedOperationException - if the JVM does not support
redefinition or the redefinition made unsupported changesClassFormatError - if a class file is not validNoClassDefFoundError - if a class name is not equal to the name
in the class file specifiedUnsupportedClassVersionError - if the class file version numbers
are unsupportedClassCircularityError - if circularity occured with the new
classesLinkageError - if a linkage error occursNullPointerException - if the definitions array is null, or any
of its elementisRedefineClassesSupported(),
addTransformer(java.lang.instrument.ClassFileTransformer),
ClassFileTransformerClass[] getAllLoadedClasses()
Class[] getInitiatedClasses(ClassLoader loader)
loader - the loaderlong getObjectSize(Object objectToSize)
objectToSize - the objectNullPointerException - if objectToSize is null.