Name
ClassFileTransformer
Synopsis
A
ClassFileTransformer
registered through an
Instrumentation object is offered a chance to
transform every class that is subsequently loaded or redefined. The
final argument to transform( ) is a byte array
that contains the raw bytes of the class file (or bytes returned by a
previously invoked ClassFileTransformer). If the
transform( )
method wishes to transform the class, it should return the
transformed bytes in a newly allocated array. The array passed to
transform( ) should not be modified. If the
transform( ) method does not wish to transform a
given class, it should return null.
public interface ClassFileTransformer { // Public Instance Methods byte[ ] transform(ClassLoader loader, String className, Class<?> classBeingRedefined, java.security.ProtectionDomain protectionDomain, byte[ ] classfileBuffer) throws IllegalClassFormatException; }
Passed To
Instrumentation.{addTransformer( ),
removeTransformer( )}
Become an O’Reilly member and get unlimited access to this title plus top books and audiobooks from O’Reilly and nearly 200 top publishers, thousands of courses curated by job role, 150+ live events each month,
and much more.
Read now
Unlock full access