Class BinaryStubDataTest
AnnotationFileElementTypes.loadBinaryStubData turns an IOException into a
fallback to text parsing, and anything else into "please report a Checker Framework bug". A
corrupt file -- a truncated download, a bad transfer, a bit flip -- must therefore surface as an
IOException. That is the whole reason BinaryStubData.readCount and
readStringIndex exist, so each is exercised here with the input it is meant to reject: a count
that cannot be a real count, and an index that points outside the string pool.
The files are hand-built rather than produced by the writer and then damaged: the point is to reject bytes the writer would never emit, and building them directly says exactly which byte is wrong.
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionvoidAn annotation-pool index that points outside the pool must be rejected while the file is read.voidAn absurdly large count must be rejected, not allocated.voidA negative count must be rejected, not passed tonew String[-1].voidA string-pool index that points outside the pool must be rejected while the file is read.voidA file that stops in the middle of a record must be rejected.voidA file that is not a binary stub file at all must be rejected.voidA file written by a different version of the format must be rejected.
-
Constructor Details
-
BinaryStubDataTest
public BinaryStubDataTest()
-
-
Method Details
-
negativeCountIsMalformed
A negative count must be rejected, not passed tonew String[-1].- Throws:
IOException
-
hugeCountIsMalformed
An absurdly large count must be rejected, not allocated.- Throws:
IOException
-
stringPoolIndexOutsideThePoolIsMalformed
A string-pool index that points outside the pool must be rejected while the file is read.The bad index here is a field name, and every other byte of the file is valid. That is the case that matters: a field's name index is not dereferenced while reading (unlike a class's, which indexes
classesimmediately), but only later, when the class's records are applied -- outside anyIOExceptionhandler. Left unvalidated, this file parses successfully, is cached, and then throwsArrayIndexOutOfBoundsExceptionthe first time the class is used, crashing the compilation.- Throws:
IOException
-
annotationPoolIndexOutsideThePoolIsMalformed
An annotation-pool index that points outside the pool must be rejected while the file is read.Similar to string pool indices, an annotation index is only dereferenced later during application. Left unvalidated, an out-of-bounds index throws ArrayIndexOutOfBoundsException later on, crashing the compiler.
- Throws:
IOException
-
truncatedFileIsMalformed
A file that stops in the middle of a record must be rejected.- Throws:
IOException
-
wrongMagicIsMalformed
A file that is not a binary stub file at all must be rejected.- Throws:
IOException
-
wrongVersionIsMalformed
A file written by a different version of the format must be rejected.- Throws:
IOException
-