All Downloads are FREE. Search and download functionalities are using the official Maven repository.

org.checkerframework.dataflow.cfg.builder.TryCatchFrame Maven / Gradle / Ivy

Go to download

dataflow-shaded is a dataflow framework based on the javac compiler. It differs from the org.checkerframework:dataflow artifact in two ways. First, the packages in this artifact have been renamed to org.checkerframework.shaded.*. Second, unlike the dataflow artifact, this artifact contains the dependencies it requires.

There is a newer version: 3.42.0-eisop5
Show newest version
package org.checkerframework.dataflow.cfg.builder;

import org.plumelib.util.IPair;

import java.util.List;
import java.util.Set;
import java.util.StringJoiner;

import javax.lang.model.type.DeclaredType;
import javax.lang.model.type.TypeKind;
import javax.lang.model.type.TypeMirror;
import javax.lang.model.type.TypeVariable;
import javax.lang.model.type.UnionType;
import javax.lang.model.util.Types;

/**
 * A TryCatchFrame contains an ordered list of catch labels that apply to exceptions with specific
 * types.
 */
/*package-private*/ class TryCatchFrame implements TryFrame {
    /** The Types utilities. */
    protected final Types types;

    /** An ordered list of pairs because catch blocks are ordered. */
    protected final List> catchLabels;

    /**
     * Construct a TryCatchFrame.
     *
     * @param types the Types utilities
     * @param catchLabels the catch labels
     */
    public TryCatchFrame(Types types, List> catchLabels) {
        this.types = types;
        this.catchLabels = catchLabels;
    }

    @Override
    public String toString() {
        if (this.catchLabels.isEmpty()) {
            return "TryCatchFrame: no catch labels.";
        } else {
            StringJoiner sb = new StringJoiner(System.lineSeparator(), "TryCatchFrame: ", "");
            for (IPair ptml : this.catchLabels) {
                sb.add(ptml.first.toString() + " -> " + ptml.second.toString());
            }
            return sb.toString();
        }
    }

    /**
     * Given a type of thrown exception, add the set of possible control flow successor {@link
     * Label}s to the argument set. Return true if the exception is known to be caught by one of
     * those labels and false if it may propagate still further.
     */
    @Override
    public boolean possibleLabels(TypeMirror thrown, Set




© 2015 - 2025 Weber Informatics LLC | Privacy Policy