org.checkerframework.dataflow.cfg.builder.TryCatchFrame Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of checker Show documentation
Show all versions of checker Show documentation
The Checker Framework enhances Java's type system to
make it more powerful and useful. This lets software developers
detect and prevent errors in their Java programs.
The Checker Framework includes compiler plug-ins ("checkers")
that find bugs or verify their absence. It also permits you to
write your own compiler plug-ins.
The 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