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. |
java.lang.Class[] |
getAllLoadedClasses()
Get all the classes loaded by the JVM.
|
java.lang.Class[] |
getInitiatedClasses(java.lang.ClassLoader loader)
Get all the classes loaded by a given class loader
|
long |
getObjectSize(java.lang.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 addjava.lang.NullPointerException - if transformer is nullboolean removeTransformer(ClassFileTransformer transformer)
transformer - the transformer to removejava.lang.NullPointerException - if transformer is nullboolean isRedefineClassesSupported()
void redefineClasses(ClassDefinition[] definitions) throws java.lang.ClassNotFoundException, UnmodifiableClassException
definitions - an array of classes to redefinejava.lang.ClassNotFoundException - if a class cannot be foundUnmodifiableClassException - if a class cannot be modifiedjava.lang.UnsupportedOperationException - if the JVM does not support
redefinition or the redefinition made unsupported changesjava.lang.ClassFormatError - if a class file is not validjava.lang.NoClassDefFoundError - if a class name is not equal to the name
in the class file specifiedjava.lang.UnsupportedClassVersionError - if the class file version numbers
are unsupportedjava.lang.ClassCircularityError - if circularity occured with the new
classesjava.lang.LinkageError - if a linkage error occursjava.lang.NullPointerException - if the definitions array is null, or any
of its elementisRedefineClassesSupported(),
addTransformer(java.lang.instrument.ClassFileTransformer),
ClassFileTransformerjava.lang.Class[] getAllLoadedClasses()
java.lang.Class[] getInitiatedClasses(java.lang.ClassLoader loader)
loader - the loaderlong getObjectSize(java.lang.Object objectToSize)
objectToSize - the objectjava.lang.NullPointerException - if objectToSize is null.