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( )}
Get Java in a Nutshell, 5th Edition now with the O’Reilly learning platform.
O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.