java.lang.Object
org.checkerframework.afu.annotator.Main

public class Main extends Object
This is the main class for the annotator, which inserts annotations in Java source code. You can call it as java org.checkerframework.afu.annotator.Main or by using the shell script insert-annotations-to-source.

It takes as input

  • annotation (index) files, which indicate the annotations to insert
  • Java source files, into which the annotator inserts annotations
Annotations that are not for the specified Java files are ignored.

The command-line options are as follows:

  • General options
    • -d --outdir=directory. Directory in which output files are written. [default: annotated/]
    • -i --in-place=boolean. If true, overwrite original source files (making a backup first). Furthermore, if the backup files already exist, they are used instead of the .java files. This behavior permits a user to tweak the .jaif file and re-run the annotator.

      Note that if the user runs the annotator with --in-place, makes edits, and then re-runs the annotator with this --in-place option, those edits are lost. Similarly, if the user runs the annotator twice in a row with --in-place, only the last set of annotations will appear in the codebase at the end.

      To preserve changes when using the --in-place option, first remove the backup files. Or, use the -d . option, which makes (and reads) no backup, instead of --in-place. [default: false]

    • -a --abbreviate=boolean. If true, insert import statements as necessary. [default: true]
    • -o --omit-annotation=string. Omit given annotation
    • --nowarn=boolean. Suppress warnings about disallowed insertions [default: false]
    • --convert-jaifs=boolean. Convert JAIFs to AST Path format, but do no insertion into source [default: false]
    • -h --help=boolean. Print usage information and exit [default: false]
  • Debugging options
    • -v --verbose=boolean. Verbose (print progress information) [default: false]
    • --debug=boolean. Debug (print debug information) [default: false]
    • --print-error-stack=boolean. Print error stack [default: false]
  • Field Details

    • outdir

      public static String outdir
      Directory in which output files are written.
    • in_place

      public static boolean in_place
      If true, overwrite original source files (making a backup first). Furthermore, if the backup files already exist, they are used instead of the .java files. This behavior permits a user to tweak the .jaif file and re-run the annotator.

      Note that if the user runs the annotator with --in-place, makes edits, and then re-runs the annotator with this --in-place option, those edits are lost. Similarly, if the user runs the annotator twice in a row with --in-place, only the last set of annotations will appear in the codebase at the end.

      To preserve changes when using the --in-place option, first remove the backup files. Or, use the -d . option, which makes (and reads) no backup, instead of --in-place.

    • abbreviate

      public static boolean abbreviate
      If true, insert import statements as necessary.
    • omit_annotation

      public static String omit_annotation
      Don't insert the given annotation.
    • nowarn

      public static boolean nowarn
    • convert_jaifs

      public static boolean convert_jaifs
    • help

      public static boolean help
    • verbose

      public static boolean verbose
    • debug

      public static boolean debug
    • temporaryDebug

      public static boolean temporaryDebug
    • hasExplicitConstructor

      public static Map<String,Boolean> hasExplicitConstructor
      Maps from binary class name to whether the class has any explicit constructor.
  • Constructor Details

    • Main

      public Main()
  • Method Details

    • main

      public static void main(String[] args) throws IOException
      Runs the annotator, parsing the source and spec files and applying the annotations.
      Parameters:
      args - .jaif files and/or .java files and/or @arg-files, in any order
      Throws:
      IOException
    • leafString

      public static String leafString(TreePath path)
      Returns the representation of the leaf of the path.
      Parameters:
      path - a path whose leaf to format
      Returns:
      the representation of the leaf of the path
    • treeToString

      public static String treeToString(Tree node)
      Returns the first 80 characters of the tree's printed representation, on one line.
      Parameters:
      node - a tree to format with truncation
      Returns:
      the first 80 characters of the tree's printed representation, on one line
    • firstLine

      public static String firstLine(String s)
      Returns the first non-empty line of the string, adding an ellipsis (...) if the string was truncated.
      Parameters:
      s - a string to truncate
      Returns:
      the first non-empty line of the argument
    • first80

      public static String first80(String s)
      Returns the first 80 characters of the string, adding an ellipsis (...) if the string was truncated.
      Parameters:
      s - a string to truncate
      Returns:
      the first 80 characters of the string
    • removeArgs

      public static org.plumelib.util.IPair<String,String> removeArgs(String s)
      Separates the annotation class from its arguments.
      Parameters:
      s - the string representation of an annotation
      Returns:
      given @foo(bar) it returns the pair { @foo, (bar) }