Class AnnotationFileUtil

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

public class AnnotationFileUtil extends Object
Utility class for annotation files (stub files and ajava files).
  • Method Details

    • partitionQualifiedName

      public static AnnotationFileUtil.QualifiedName partitionQualifiedName(String imported)
      Splits a name (which comes from an import statement) into the part before the last period and the part after the last period.
      Parameters:
      imported - the name to split
      Returns:
      the type name and the member name
    • findFileSystemLocation

      public static @Nullable File findFileSystemLocation(String location)
      Returns the file system location that a path names. Looks for it as an absolute path or relative to the current directory, then relative to the user.dir system property, then relative to the test.src system property (which jtreg sets to the directory that contains the test).
      Parameters:
      location - a relative or absolute path
      Returns:
      the file or directory that location names, or null if none exists
    • forEachAnnotationFile

      public static void forEachAnnotationFile(File location, AnnotationFileUtil.AnnotationFileType fileType, Consumer<AnnotationFileResource> action)
      Runs action on each annotation file of type fileType at the given file system location. Passes the files under a directory in order of their names, and the entries in an archive in the order that the archive stores them.

      If location is a directory, recurses on all files contained in it. If location is a jarfile that cannot be opened or a directory that cannot be listed, passes a resource whose AnnotationFileResource.getInputStream() throws an exception, so the client reports the error rather than treating location as empty.

      Parameters:
      location - an annotation file (a stub file or ajava file), a jarfile, or a directory
      fileType - type of annotation files to pass to action
      action - the operation to perform on each annotation file
    • isCanonicalConstructor

      public static boolean isCanonicalConstructor(ExecutableElement elt, Types types)
      Returns true if the given ExecutableElement is the canonical constructor of a record (i.e., the parameter types of the constructor correspond to the parameter types of the record components, ignoring annotations).
      Parameters:
      elt - the constructor/method to check
      types - the Types instance to use for comparing types
      Returns:
      true if elt is the canonical constructor of the record containing it