|
Préférences
Moteurs de recherche
|
||||||||||||||||
JavaTM 2 Platform Std. Ed. v1.5.0
java.lang.instrument
|
Method Summary | |
---|---|
void |
addTransformer(ClassFileTransformer transformer)
Registers the supplied transformer. |
Class[] |
getAllLoadedClasses()
Returns an array of all classes currently loaded by the JVM. |
Class[] |
getInitiatedClasses(ClassLoader loader)
Returns an array of all classes for which loader is an initiating loader. |
long |
getObjectSize(Object objectToSize)
Returns an implementation-specific approximation of the amount of storage consumed by the specified object. |
boolean |
isRedefineClassesSupported()
Returns whether or not the current JVM configuration supports redefinition of classes. |
void |
redefineClasses(ClassDefinition[] definitions)
Redefine the supplied set of classes using the supplied class files. |
boolean |
removeTransformer(ClassFileTransformer transformer)
Unregisters the supplied transformer. |
Method Detail |
---|
void addTransformer(ClassFileTransformer transformer)
addTransformer
will always see the class files before any external JVMTI ClassFileLoadHook event listener does.
This method is intended for use in instrumentation, as described in the class specification.
transformer
- the transformer to register
NullPointerException
- if passed a null
transformerboolean removeTransformer(ClassFileTransformer transformer)
transformer
- the transformer to unregister
NullPointerException
- if passed a null
transformerboolean isRedefineClassesSupported()
redefineClasses(java.lang.instrument.ClassDefinition[])
void redefineClasses(ClassDefinition[] definitions) throws ClassNotFoundException, UnmodifiableClassException
If a redefined method has active stack frames, those active frames continue to run the bytecodes of the original method. The redefined method will be used on new invokes.
This method does not cause any initialization except that which would occur under the customary JVM semantics. In other words, redefining a class does not cause its initializers to be run. The values of static variables will remain as they were prior to the call.
Instances of the redefined class are not affected.
Registered transformers will be called before the redefine operation is applied.
The redefinition may change method bodies, the constant pool and attributes. The redefinition must not add, remove or rename fields or methods, change the signatures of methods, or change inheritance. These restrictions maybe be lifted in future versions.
A zero-length definitions
array is allowed, in this case, this
method does nothing.
If this method throws an exception, no classes have been redefined.
This method is intended for use in instrumentation, as described in the class specification.
definitions
- array of classes to redefine with corresponding definitions
ClassNotFoundException
- if a specified class cannot be found
UnmodifiableClassException
- if a specified class cannot be modified
UnsupportedOperationException
- if the current configuration of the JVM does not allow
redefinition (isRedefineClassesSupported()
is false) or the redefinition made unsupported changes
ClassFormatError
- if the data did not contain a valid class
NoClassDefFoundError
- if the name in the class file is not equal to the name of the class
UnsupportedClassVersionError
- if the class file version numbers are not supported
ClassCircularityError
- if the new classes contain a circularity
LinkageError
- if a linkage error occurs
NullPointerException
- if the supplied definitions array or any of its components is null
.isRedefineClassesSupported()
,
addTransformer(java.lang.instrument.ClassFileTransformer)
,
ClassFileTransformer
Class[] getAllLoadedClasses()
Class[] getInitiatedClasses(ClassLoader loader)
loader
is an initiating loader.
If the supplied loader is null
, classes initiated by the bootstrap class
loader are returned.
loader
- the loader whose initiated class list will be returned
long getObjectSize(Object objectToSize)
objectToSize
- the object to size
NullPointerException
- if the supplied Object is null
.