Class RemoveAnnotationsForInference

java.lang.Object
org.checkerframework.framework.stub.RemoveAnnotationsForInference

public class RemoveAnnotationsForInference extends Object
Process Java source files to remove annotations that ought to be inferred.

Removes annotations from all files in the given directories. Modifies the files in place.

Does not remove trusted annotations: those that the checker trusts rather than verifies.

Also does not remove annotations that the user requests to keep in the source code. Provide a list of annotations to keep via the -keepFile command line argument, which must be the first argument to this program if it is present. The second argument to the program should be the path to the keep file. The keep file itself should be a list of newline-separated annotation names (without @ symbols). Both the simple and fully-qualified name of each annotation usually should be included in the keep file (simple string-matching between the annotations in the keep file and the annotation names used in the source code whose annotations are being removed is used for annotation comparison). TODO: remove this restriction?

Does not remove annotations at locations where inference does no work:

  • within the scope of a relevant @SuppressWarnings
  • within the scope of @IgnoreInWholeProgramInference or an annotation meta-annotated with that, such as @Option
After removing annotations, javac may issue "warning: [cast] redundant cast to ..." if -Alint:cast (or -Alint:all which implies it) is passed to javac. You can suppress the warning by passing -Alint:-cast to javac.
  • Method Details

    • main

      public static void main(String[] args)
      Processes each provided command-line argument; see class documentation for details.
      Parameters:
      args - command-line arguments: directories to process