org.checkerframework.dataflow.cfg.builder.TryFinallyScopeCell 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.
package org.checkerframework.dataflow.cfg.builder;
import org.checkerframework.checker.nullness.qual.MonotonicNonNull;
import org.checkerframework.javacutil.BugInCF;
/** Storage cell for a single Label, with tracking whether it was accessed. */
class TryFinallyScopeCell {
/** The label. If it is null, then it will be lazily set if {@link #accessLabel} is called. */
private @MonotonicNonNull Label label;
/** True if the label has been accessed. */
private boolean accessed;
/** Create a TryFinallyScopeCell with no label; the label will be lazily created if needed. */
protected TryFinallyScopeCell() {
this.accessed = false;
}
protected TryFinallyScopeCell(Label label) {
assert label != null;
this.label = label;
this.accessed = false;
}
public Label accessLabel() {
if (label == null) {
label = new Label();
}
accessed = true;
return label;
}
public Label peekLabel() {
if (label == null) {
throw new BugInCF("called peekLabel prematurely");
}
return label;
}
public boolean wasAccessed() {
return accessed;
}
}