Search in sources :

Example 26 with RequiresNonNull

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);
}
Also used : AnnotationMirror(javax.lang.model.element.AnnotationMirror) NonNull(org.checkerframework.checker.nullness.qual.NonNull) RequiresNonNull(org.checkerframework.checker.nullness.qual.RequiresNonNull) QualifierKind(org.checkerframework.framework.util.QualifierKind) RequiresNonNull(org.checkerframework.checker.nullness.qual.RequiresNonNull)

Example 27 with RequiresNonNull

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));
}
Also used : ExceptionBlock(org.checkerframework.dataflow.cfg.block.ExceptionBlock) SpecialBlock(org.checkerframework.dataflow.cfg.block.SpecialBlock) Block(org.checkerframework.dataflow.cfg.block.Block) RegularBlock(org.checkerframework.dataflow.cfg.block.RegularBlock) ConditionalBlock(org.checkerframework.dataflow.cfg.block.ConditionalBlock) LocalVariableNode(org.checkerframework.dataflow.cfg.node.LocalVariableNode) UnderlyingAST(org.checkerframework.dataflow.cfg.UnderlyingAST) RequiresNonNull(org.checkerframework.checker.nullness.qual.RequiresNonNull)

Example 28 with RequiresNonNull

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.");
    }
}
Also used : ReturnNode(org.checkerframework.dataflow.cfg.node.ReturnNode) SpecialBlock(org.checkerframework.dataflow.cfg.block.SpecialBlock) BugInCF(org.checkerframework.javacutil.BugInCF) UnderlyingAST(org.checkerframework.dataflow.cfg.UnderlyingAST) RequiresNonNull(org.checkerframework.checker.nullness.qual.RequiresNonNull)

Example 29 with RequiresNonNull

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);
    }
}
Also used : FlacStreamMetadata(com.google.android.exoplayer2.extractor.FlacStreamMetadata) Metadata(com.google.android.exoplayer2.metadata.Metadata) IOException(java.io.IOException) FlacStreamMetadata(com.google.android.exoplayer2.extractor.FlacStreamMetadata) Nullable(androidx.annotation.Nullable) OutputFrameHolder(com.google.android.exoplayer2.ext.flac.FlacBinarySearchSeeker.OutputFrameHolder) EnsuresNonNull(org.checkerframework.checker.nullness.qual.EnsuresNonNull) RequiresNonNull(org.checkerframework.checker.nullness.qual.RequiresNonNull)

Example 30 with RequiresNonNull

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;
}
Also used : IndexSeekMap(com.google.android.exoplayer2.extractor.IndexSeekMap) RequiresNonNull(org.checkerframework.checker.nullness.qual.RequiresNonNull)

Aggregations

RequiresNonNull (org.checkerframework.checker.nullness.qual.RequiresNonNull)43 Nullable (androidx.annotation.Nullable)12 Format (com.google.android.exoplayer2.Format)10 SuppressLint (android.annotation.SuppressLint)4 TrackOutput (com.google.android.exoplayer2.extractor.TrackOutput)3 MediaPeriodId (com.google.android.exoplayer2.source.MediaSource.MediaPeriodId)3 IOException (java.io.IOException)3 ByteBuffer (java.nio.ByteBuffer)3 Intent (android.content.Intent)2 Paint (android.graphics.Paint)2 Uri (android.net.Uri)2 Bundle (android.os.Bundle)2 TextPaint (android.text.TextPaint)2 DecoderInputBuffer (com.google.android.exoplayer2.decoder.DecoderInputBuffer)2 DefaultExtractorInput (com.google.android.exoplayer2.extractor.DefaultExtractorInput)2 Transformer (com.google.android.exoplayer2.transformer.Transformer)2 EnsuresNonNull (org.checkerframework.checker.nullness.qual.EnsuresNonNull)2 UnderlyingAST (org.checkerframework.dataflow.cfg.UnderlyingAST)2 SpecialBlock (org.checkerframework.dataflow.cfg.block.SpecialBlock)2 TypeSystemError (org.checkerframework.javacutil.TypeSystemError)2