java.lang.instrument
Interface ClassFileTransformer
public interface ClassFileTransformer
This interface should be implemented by classes wishing to transform
classes bytecode when defining or redefining classes.
- Since:
- 1.5
- See Also:
Instrumentation,
Instrumentation.addTransformer(java.lang.instrument.ClassFileTransformer),
Instrumentation.removeTransformer(java.lang.instrument.ClassFileTransformer)
|
Method Summary |
byte[] |
transform(ClassLoader loader,
String className,
Class<?> classBeingRedefined,
ProtectionDomain protectionDomain,
byte[] classfileBuffer)
Implementation of this method transforms a class by redefining its
bytecodes. |
transform
byte[] transform(ClassLoader loader,
String className,
Class<?> classBeingRedefined,
ProtectionDomain protectionDomain,
byte[] classfileBuffer)
throws IllegalClassFormatException
- Implementation of this method transforms a class by redefining its
bytecodes. Once a ClassFileTransformer object registers itself to the
Instrumentation object, this method will be called each time a class is
defined (
ClassLoader.defineClass) or redefined
(Instrumentation.redefineClasses)
- Parameters:
loader - the loader of the classclassName - the name of the class with packages separated with "/"classBeingRedefined - the class being redefined if it's the case,
null otherwiseprotectionDomain - the protection domain of the class being defined or
redefinedclassfileBuffer - the input byte buffer in class file format
- Returns:
- a class file buffer or null when no transformation has been performed
- Throws:
IllegalClassFormatException - if the byte buffer does not represent
a well-formed class file- See Also:
Instrumentation.redefineClasses(java.lang.instrument.ClassDefinition[])