Klasse ClassPatcher

java.lang.Object
com.dua3.cabe.processor.ClassPatcher

public class ClassPatcher extends Object
The ClassPatcher class is responsible for patching class files by adding assertions for nullability checks on method parameters. It collects information about the class file, including package information and parameter annotations, and modifies the class file by injecting the necessary code.
  • Konstruktordetails

    • ClassPatcher

      public ClassPatcher(Collection<Path> classpath)
      This class represents a ClassPatcher object that manipulates class files in a given classpath.
      Parameter:
      classpath - the compile classpath
  • Methodendetails

    • processFolder

      public void processFolder(Path classFolder) throws IOException, ClassFileProcessingFailedException
      Process a folder containing class files.
      Parameter:
      classFolder - the folder to process
      Löst aus:
      IOException - if an I/O error occurs
      ClassFileProcessingFailedException - if processing of a class file fails
    • instrumentClassFile

      public void instrumentClassFile(Path classFile) throws ClassFileProcessingFailedException, IOException
      Instruments a class file by adding null-check assertions for method parameters.
      Parameter:
      classFile - the path to the class file to be instrumented
      Löst aus:
      ClassFileProcessingFailedException - if processing of the class file fails
      IOException - if an I/O error occurs
    • getParameterTypes

      public static String[] getParameterTypes(javassist.CtBehavior method)
      Retrieves the parameter types of a given method.
      Parameter:
      method - the method to retrieve parameter types for
      Gibt zurück:
      an array of Strings representing the parameter types of the method
      Löst aus:
      IllegalStateException - if the parameter descriptor is malformed