Class ClassFileWriter
java.lang.Object
org.checkerframework.afu.scenelib.io.classfile.ClassFileWriter
A
ClassFileWriter provides methods for inserting annotations from an AScene into
a class file.-
Field Summary
Fields -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionstatic voidinsert(AScene scene, InputStream input, OutputStream out, boolean overwrite) Inserts the annotations contained insceneinto the class file read fromin, and writes the resulting class file intoout.static voidInserts the annotations contained insceneinto the class file contained infileName, and write the result back intofileName.static voidInserts the annotations contained insceneinto the classin, and writes the resulting class file intoout.static voidMain method meant to be a convenient way to write annotations from an index file to a class file.
-
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
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
Inserts the annotations contained insceneinto the class file contained infileName, and write the result back intofileName.- Parameters:
scene- the scene containing the annotations to insert into a classfileName- 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 tofileName
-
insert
public static void insert(AScene scene, InputStream input, OutputStream out, boolean overwrite) throws IOException Inserts the annotations contained insceneinto the class file read fromin, and writes the resulting class file intoout.inshould be a stream of bytes that specify a valid Java class file, andoutwill contain a stream of bytes in the same format, and will also contain the annotations fromscene.- Parameters:
scene- the scene containing the annotations to insert into a classinput- the input stream from which to read a classout- the output stream the merged class should be written tooverwrite- 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 frominor writing toout
-
insert
public static void insert(AScene scene, String className, String outputFileName, boolean overwrite) throws IOException Inserts the annotations contained insceneinto the classin, and writes the resulting class file intoout.inshould be the name of a fully-qualified class, andoutshould be the name of a file to output the resulting class file to.- Parameters:
scene- the scene containing the annotations to insert into a classclassName- the fully qualified class to readoutputFileName- the name of the output file the class should be written tooverwrite- 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 frominor writing toout
-