Class AgentTransformer

java.lang.Object
com.avrix.agent.AgentTransformer
All Implemented Interfaces:
ClassFileTransformer

public class AgentTransformer extends Object implements ClassFileTransformer
The class represents a class transformer, used to change classes at boot time. It implements the ClassFileTransformer interface, which allows you to change the byte code of classes before they are loaded into the JVM.
  • Constructor Details

    • AgentTransformer

      public AgentTransformer()
  • Method Details

    • transform

      public byte[] transform(ClassLoader loader, String className, Class<?> classBeingRedefined, ProtectionDomain protectionDomain, byte[] classfileBuffer) throws IllegalClassFormatException
      The transform method is called for each class that is loaded into the JVM. It takes the byte code of the original class and returns the modified byte code. This method implementation calls the getModifyClass method of the AgentManager class to obtain the modified byte code of the class.
      Specified by:
      transform in interface ClassFileTransformer
      Parameters:
      loader - class of the loader that loads this class
      className - full class name in class path format (delimited by '/')
      classBeingRedefined - the class that is being overridden (can be null if the class is not being overridden)
      protectionDomain - the protection domain in which the class runs
      classfileBuffer - byte code of the original class
      Returns:
      the modified byte code of the class
      Throws:
      IllegalClassFormatException - if the class bytecode cannot be transformed