Class BinaryStubReader

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

public class BinaryStubReader extends Object
Applies annotation data from a BinaryStubData.ClassRecord to a checker's AnnotationFileParser.AnnotationFileAnnotations. This translates the compact structural binary representation back into AnnotationMirror and AnnotatedTypeMirror objects that the framework uses during type-checking, matching the semantics of the text-based AnnotationFileParser. It serves both the annotated JDK (annotated-jdk.bin.gz, applied lazily per requested class) and the built-in checker stub files (*.astub.bin.gz, applied eagerly at checker initialization with @FromStubFile marking).

Annotations that cannot be resolved (e.g. JDK-internal annotations like @DefinedBy that are absent from the annotation-processor classpath) are silently skipped, matching the behavior of the text-based AnnotationFileParser. Annotations that are not supported qualifiers of the current checker are filtered out by AnnotatedTypeMirror.addAnnotation(AnnotationMirror) when they are applied to a type.

User-supplied stub files take precedence: if an entry already exists in AnnotationFileParser.AnnotationFileAnnotations.atypes it is not overwritten, and declaration annotations are merged by annotation name rather than replaced.

A stub method that the enclosing class only inherits is applied as a fake override (see applyFakeOverride(org.checkerframework.framework.stub.BinaryStubData.TypeAnno[], java.lang.String, javax.lang.model.element.TypeElement, java.lang.String, org.checkerframework.framework.stub.BinaryStubData, org.checkerframework.framework.type.AnnotatedTypeFactory, org.checkerframework.framework.stub.AnnotationFileElementTypes, org.checkerframework.framework.stub.AnnotationFileParser.AnnotationFileAnnotations)). Classes that are not present in the binary stub -- e.g. a file the writer failed to serialize, or a user-supplied -Astubs file, which is always text-parsed -- fall through to the text-based AnnotationFileParser path.

Semantic equivalence of this class and the text parser is enforced by BinaryStubDiffChecker (option -AbinaryStubDiffCheck); run NullnessBinaryStubDiffTest after changing either side.

See Also: