Class ClassFileWriter

java.lang.Object
org.checkerframework.afu.scenelib.io.classfile.ClassFileWriter

public class ClassFileWriter extends Object
A ClassFileWriter provides methods for inserting annotations from an AScene into a class file.
  • Field Summary

    Fields
    Modifier and Type
    Field
    Description
    static boolean
     
    static boolean
     
    static boolean
     
  • Constructor Summary

    Constructors
    Constructor
    Description
     
  • Method Summary

    Modifier and Type
    Method
    Description
    static void
    insert(AScene scene, InputStream input, OutputStream out, boolean overwrite)
    Inserts the annotations contained in scene into the class file read from in, and writes the resulting class file into out .
    static void
    insert(AScene scene, String fileName, boolean overwrite)
    Inserts the annotations contained in scene into the class file contained in fileName , and write the result back into fileName.
    static void
    insert(AScene scene, String className, String outputFileName, boolean overwrite)
    Inserts the annotations contained in scene into the class in, and writes the resulting class file into out .
    static void
    main(String[] args)
    Main method meant to be a convenient way to write annotations from an index file to a class file.

    Methods inherited from class java.lang.Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
  • Field Details

    • help

      public static boolean help
    • version

      public static boolean version
    • verbose

      public static boolean verbose
  • Constructor Details

    • ClassFileWriter

      public ClassFileWriter()
  • Method Details

    • main

      public static void main(String[] args) throws IOException
      Main method meant to be a convenient way to write annotations from an index file to a class file. For programmatic access to this tool, one should probably use the insert() methods instead.

      Usage: java org.checkerframework.afu.scenelib.io.ClassFileWriter options [classfile indexfile] ...

      options include:

         -h, --help   print usage information and exit
         --version    print version information and exit
       
      Parameters:
      args - options and classes and index files to analyze;
      Throws:
      IOException - if a class file or index file cannot be opened/written
    • insert

      public static void insert(AScene scene, String fileName, boolean overwrite) throws IOException
      Inserts the annotations contained in scene into the class file contained in fileName , and write the result back into fileName.
      Parameters:
      scene - the scene containing the annotations to insert into a class
      fileName - the file name of the class the annotations should be inserted into. Should be a file name that can be resolved from the current working directory, which means it should end in ".class" for standard Java class files.
      overwrite - controls behavior when an annotation exists on a particular element in both the scene and the class file. If true, then the one from the scene is used; else the existing annotation in the class file is retained.
      Throws:
      IOException - if there is a problem reading from or writing to fileName
    • insert

      public static void insert(AScene scene, InputStream input, OutputStream out, boolean overwrite) throws IOException
      Inserts the annotations contained in scene into the class file read from in, and writes the resulting class file into out . in should be a stream of bytes that specify a valid Java class file, and out will contain a stream of bytes in the same format, and will also contain the annotations from scene.
      Parameters:
      scene - the scene containing the annotations to insert into a class
      input - the input stream from which to read a class
      out - the output stream the merged class should be written to
      overwrite - controls behavior when an annotation exists on a particular element in both the scene and the class file. If true, then the one from the scene is used; else the existing annotation in the class file is retained.
      Throws:
      IOException - if there is a problem reading from in or writing to out
    • insert

      public static void insert(AScene scene, String className, String outputFileName, boolean overwrite) throws IOException
      Inserts the annotations contained in scene into the class in, and writes the resulting class file into out . in should be the name of a fully-qualified class, and out should be the name of a file to output the resulting class file to.
      Parameters:
      scene - the scene containing the annotations to insert into a class
      className - the fully qualified class to read
      outputFileName - the name of the output file the class should be written to
      overwrite - controls behavior when an annotation exists on a particular element in both the scene and the class file. If true, then the one from the scene is used; else the existing annotation in the class file is retained.
      Throws:
      IOException - if there is a problem reading from in or writing to out