Class JavaStubifierTest
java.lang.Object
org.checkerframework.framework.stubifier.JavaStubifierTest
Regression test for a bug where
JavaStubifier's BinaryStubWriter was held in a
private static final field: since main can process several directories in one
invocation, and a BinaryStubWriter accumulates every class passed to process in
instance fields with no reset between calls, reusing one writer across directories made each
directory's own annotated-jdk.bin.gz also contain every earlier directory's classes.-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionvoidVerifies that processing two directories in onemain()invocation does not leak classes from the first directory into the second one's binary stub output; see the class documentation for the underlying bug.voidRegression test for the "does this file have any interesting declaration" check.voidWithJavaStubifier.SKIP_UNLOADABLE_ANNOTATIONS_FLAG, the same input succeeds instead: the unloadable annotation is dropped from the binary stub output (so the field ends up with no annotations, and the annotated-JDK writer then omits its record entirely, perBinaryStubWriterTest.jdkWriterDemotesUnannotatedMethodRecords()'s analogous case for methods), and a warning naming the annotation and the file is printed to stderr.voidBy default, an unloadable annotation aborts the whole run, and the failure names both the annotation and the source file that was being processed -- the file path used to be missing, which made finding the offending file among thousands require grepping the whole tree.voidA binary stub that cannot be written must abort the run, not leave a stale or truncated file behind.
-
Constructor Details
-
JavaStubifierTest
public JavaStubifierTest()
-
-
Method Details
-
unwritableBinaryStubAbortsRatherThanLeavingAStaleFile
A binary stub that cannot be written must abort the run, not leave a stale or truncated file behind.processused to print theIOExceptionto stderr and return. Whateverannotated-jdk.bin.gzan earlier run had left in the directory then shipped, and the checker prefers that file over the text stubs whenever it exists, so its (wrong) contents would be applied in place of the JDK's real annotations, silently.BinaryStubFileGeneratoralready treats the same file-level failure as fatal.The write is made to fail by putting a directory where the output file belongs.
- Throws:
IOException
-
eachDirectoryGetsOnlyItsOwnClasses
Verifies that processing two directories in onemain()invocation does not leak classes from the first directory into the second one's binary stub output; see the class documentation for the underlying bug.- Throws:
IOException- if a temporary file or directory cannot be created, written, or read
-
recordOnlyFileIsKept
Regression test for the "does this file have any interesting declaration" check.RecordDeclarationextendsTypeDeclaration, so the simplifiedcu.findAll(TypeDeclaration.class).isEmpty()check correctly treats a record-only file as non-empty and keeps it. This test verifies that a file containing only a record declaration is not deleted (previously it was deleted because BinaryStubWriter did not support records, but now it does).- Throws:
IOException
-
unloadableAnnotationFailsWithFilePathInMessage
By default, an unloadable annotation aborts the whole run, and the failure names both the annotation and the source file that was being processed -- the file path used to be missing, which made finding the offending file among thousands require grepping the whole tree.- Throws:
IOException
-
skipUnloadableAnnotationsFlagOmitsAnnotationAndSucceeds
WithJavaStubifier.SKIP_UNLOADABLE_ANNOTATIONS_FLAG, the same input succeeds instead: the unloadable annotation is dropped from the binary stub output (so the field ends up with no annotations, and the annotated-JDK writer then omits its record entirely, perBinaryStubWriterTest.jdkWriterDemotesUnannotatedMethodRecords()'s analogous case for methods), and a warning naming the annotation and the file is printed to stderr.- Throws:
IOException
-