This method is used to replace the definition of a class without reference to the existing class file bytes, as one might do when recompiling from source for fix-and-continue debugging. Where the existing class file bytes are to be transformed (for example in bytecode instrumentation) {@link #retransformClasses retransformClasses}should be used.
This method operates on a set in order to allow interdependent changes to more than one class at the same time (a redefinition of class A can require a redefinition of class B).
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.
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. The class file bytes are not checked, verified and installed until after the transformations have been applied, if the resultant bytes are in error this method will throw an exception.
If this method throws an exception, no classes have been redefined.
This method is intended for use in instrumentation, as described in the {@linkplain Instrumentation class specification}.
@param definitions array of classes to redefine with corresponding definitions; a zero-length array is allowed, in this case, this method does nothing
@throws java.lang.instrument.UnmodifiableClassException if a specified class cannot be modified( {@link #isModifiableClass} would return false
)
@throws java.lang.UnsupportedOperationException if the current configuration of the JVM does not allow redefinition ( {@link #isRedefineClassesSupported} is false) or the redefinition attemptedto make unsupported changes
@throws java.lang.ClassFormatError if the data did not contain a valid class
@throws java.lang.NoClassDefFoundError if the name in the class file is not equal to the name of the class
@throws java.lang.UnsupportedClassVersionError if the class file version numbers are not supported
@throws java.lang.ClassCircularityError if the new classes contain a circularity
@throws java.lang.LinkageError if a linkage error occurs
@throws java.lang.NullPointerException if the supplied definitions array or any of its componentsis null
@throws java.lang.ClassNotFoundException Can never be thrown (present for compatibility reasons only)
@see #isRedefineClassesSupported
@see #addTransformer
@see java.lang.instrument.ClassFileTransformer
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|