use of org.checkerframework.checker.nullness.qual.RequiresNonNull in project checker-framework by typetools.
the class NoElementQualifierHierarchy method createBottoms.
/**
* Creates and returns the unmodifiable set of bottom {@link AnnotationMirror}s.
*
* @return the unmodifiable set of bottom {@link AnnotationMirror}s
*/
@RequiresNonNull({ "this.kindToAnnotationMirror", "this.qualifierKindHierarchy" })
protected Set<AnnotationMirror> createBottoms(@UnderInitialization NoElementQualifierHierarchy this, ) {
Set<AnnotationMirror> bottoms = AnnotationUtils.createAnnotationSet();
for (QualifierKind bottom : qualifierKindHierarchy.getBottoms()) {
@SuppressWarnings(// All QualifierKinds are keys in kindToAnnotationMirror
"nullness:assignment") @NonNull AnnotationMirror bottomAnno = kindToAnnotationMirror.get(bottom);
bottoms.add(bottomAnno);
}
return Collections.unmodifiableSet(bottoms);
}
use of org.checkerframework.checker.nullness.qual.RequiresNonNull in project checker-framework by typetools.
the class ForwardAnalysisImpl method initInitialInputs.
@Override
@RequiresNonNull("cfg")
protected void initInitialInputs() {
worklist.process(cfg);
Block entry = cfg.getEntryBlock();
worklist.add(entry);
UnderlyingAST underlyingAST = cfg.getUnderlyingAST();
List<LocalVariableNode> parameters = getParameters(underlyingAST);
assert transferFunction != null : "@AssumeAssertion(nullness): invariant";
S initialStore = transferFunction.initialStore(underlyingAST, parameters);
thenStores.put(entry, initialStore);
elseStores.put(entry, initialStore);
inputs.put(entry, new TransferInput<>(null, this, initialStore));
}
use of org.checkerframework.checker.nullness.qual.RequiresNonNull in project checker-framework by typetools.
the class BackwardAnalysisImpl method initInitialInputs.
@Override
@RequiresNonNull("cfg")
protected void initInitialInputs() {
worklist.process(cfg);
SpecialBlock regularExitBlock = cfg.getRegularExitBlock();
SpecialBlock exceptionExitBlock = cfg.getExceptionalExitBlock();
if (worklist.depthFirstOrder.get(regularExitBlock) == null && worklist.depthFirstOrder.get(exceptionExitBlock) == null) {
throw new BugInCF("regularExitBlock and exceptionExitBlock should never both be null at the same time.");
}
UnderlyingAST underlyingAST = cfg.getUnderlyingAST();
List<ReturnNode> returnNodes = cfg.getReturnNodes();
assert transferFunction != null : "@AssumeAssertion(nullness): invariant";
S normalInitialStore = transferFunction.initialNormalExitStore(underlyingAST, returnNodes);
S exceptionalInitialStore = transferFunction.initialExceptionalExitStore(underlyingAST);
// initialize it as a start point of the analysis.
if (worklist.depthFirstOrder.get(regularExitBlock) != null) {
worklist.add(regularExitBlock);
inputs.put(regularExitBlock, new TransferInput<>(null, this, normalInitialStore));
outStores.put(regularExitBlock, normalInitialStore);
}
if (worklist.depthFirstOrder.get(exceptionExitBlock) != null) {
worklist.add(exceptionExitBlock);
inputs.put(exceptionExitBlock, new TransferInput<>(null, this, exceptionalInitialStore));
outStores.put(exceptionExitBlock, exceptionalInitialStore);
}
if (worklist.isEmpty()) {
throw new BugInCF("The worklist needs at least one exit block as starting point.");
}
if (inputs.isEmpty() || outStores.isEmpty()) {
throw new BugInCF("At least one input and one output store are required.");
}
}
use of org.checkerframework.checker.nullness.qual.RequiresNonNull in project ExoPlayer by google.
the class FlacExtractor method decodeStreamMetadata.
// Requires initialized.
@RequiresNonNull({ "decoderJni", "extractorOutput", "trackOutput" })
// Ensures stream metadata decoded.
@EnsuresNonNull({ "streamMetadata", "outputFrameHolder" })
@SuppressWarnings("nullness:contracts.postcondition")
private void decodeStreamMetadata(ExtractorInput input) throws IOException {
if (streamMetadataDecoded) {
return;
}
FlacDecoderJni flacDecoderJni = decoderJni;
FlacStreamMetadata streamMetadata;
try {
streamMetadata = flacDecoderJni.decodeStreamMetadata();
} catch (IOException e) {
flacDecoderJni.reset(/* newPosition= */
0);
input.setRetryPosition(/* position= */
0, e);
throw e;
}
streamMetadataDecoded = true;
if (this.streamMetadata == null) {
this.streamMetadata = streamMetadata;
outputBuffer.reset(streamMetadata.getMaxDecodedFrameSize());
outputFrameHolder = new OutputFrameHolder(ByteBuffer.wrap(outputBuffer.getData()));
binarySearchSeeker = outputSeekMap(flacDecoderJni, streamMetadata, input.getLength(), extractorOutput, outputFrameHolder);
@Nullable Metadata metadata = streamMetadata.getMetadataCopyWithAppendedEntriesFrom(id3Metadata);
outputFormat(streamMetadata, metadata, trackOutput);
}
}
use of org.checkerframework.checker.nullness.qual.RequiresNonNull in project ExoPlayer by google.
the class FlvExtractor method readTagData.
/**
* Reads the body of a tag from the provided {@link ExtractorInput}.
*
* @param input The {@link ExtractorInput} from which to read.
* @return True if the data was consumed by a reader. False if it was skipped.
* @throws IOException If an error occurred reading or parsing data from the source.
*/
@RequiresNonNull("extractorOutput")
private boolean readTagData(ExtractorInput input) throws IOException {
boolean wasConsumed = true;
boolean wasSampleOutput = false;
long timestampUs = getCurrentTimestampUs();
if (tagType == TAG_TYPE_AUDIO && audioReader != null) {
ensureReadyForMediaOutput();
wasSampleOutput = audioReader.consume(prepareTagData(input), timestampUs);
} else if (tagType == TAG_TYPE_VIDEO && videoReader != null) {
ensureReadyForMediaOutput();
wasSampleOutput = videoReader.consume(prepareTagData(input), timestampUs);
} else if (tagType == TAG_TYPE_SCRIPT_DATA && !outputSeekMap) {
wasSampleOutput = metadataReader.consume(prepareTagData(input), timestampUs);
long durationUs = metadataReader.getDurationUs();
if (durationUs != C.TIME_UNSET) {
extractorOutput.seekMap(new IndexSeekMap(metadataReader.getKeyFrameTagPositions(), metadataReader.getKeyFrameTimesUs(), durationUs));
outputSeekMap = true;
}
} else {
input.skipFully(tagDataSize);
wasConsumed = false;
}
if (!outputFirstSample && wasSampleOutput) {
outputFirstSample = true;
mediaTagTimestampOffsetUs = metadataReader.getDurationUs() == C.TIME_UNSET ? -tagTimestampUs : 0;
}
// There's a 4 byte previous tag size before the next header.
bytesToNextTagHeader = 4;
state = STATE_SKIPPING_TO_TAG_HEADER;
return wasConsumed;
}
Aggregations