Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -195,6 +195,7 @@ public class Main {
// TODO: remove this.
public static boolean temporaryDebug = false;

@SuppressWarnings("resourceleak:required.method.not.known") // Not relevant to resources
private static ElementVisitor<Void, AElement> classFilter =
new ElementVisitor<Void, AElement>() {
<K, V extends AElement> Void filter(VivifyingMap<K, V> vm0, VivifyingMap<K, V> vm1) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@
*
* @param <N> common supertype of the AST nodes
*/
@SuppressWarnings("resourceleak:required.method.not.known") // Not relevant to resources
public abstract class TypeASTMapper<N> {
/** Constructs a {@link TypeASTMapper}. A {@link TypeASTMapper} stores no state. */
protected TypeASTMapper() {}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1433,6 +1433,7 @@ public String toString() {
*
* @param <E> type of stack elements
*/
@SuppressWarnings("resourceleak:required.method.not.known") // Not relevant to resources
class ImmutableStack<E> {

// The stack is implemented as a linked list:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -289,6 +289,7 @@ public Void visitElement(AElement minuend, Pair<AElement, AElement> eltPair) {
* Calculates difference between {@code minuend} and first component of {@code eltPair}, adding
* results to second component of {@code eltPair}.
*/
@SuppressWarnings("resourceleak:required.method.not.known") // Not relevant to resources
private <K, V extends AElement> void visitElements(
VivifyingMap<K, V> minuend, VivifyingMap<K, V> subtrahend, VivifyingMap<K, V> difference) {
if (minuend != null) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
* A simple implementation of {@link KeyedSet} backed by an insertion-order {@link
* java.util.LinkedHashMap} and its {@link java.util.LinkedHashMap#values() value collection}.
*/
@SuppressWarnings("resourceleak:required.method.not.known") // Not relevant to resources
public class LinkedHashKeyedSet<K, V> extends AbstractSet<V> implements KeyedSet<K, V> {
private final Keyer<? extends K, ? super V> keyer;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

import java.util.Iterator;
import java.util.Map;
import org.checkerframework.checker.mustcall.qual.MustCall;

/**
* A {@link VivifyingMap} is a map with two additional methods:
Expand All @@ -12,7 +13,7 @@
* <li>{@link #prune} removes empty values
* </ul>
*/
public abstract class VivifyingMap<K, V> extends WrapperMap<K, V> {
public abstract class VivifyingMap<K, V> extends WrapperMap<K, @MustCall({}) V> {
/**
* Constructs a new {@link VivifyingMap} backed by the given map. All reads and writes to this
* {@link VivifyingMap} go through to the backing map. However, since the {@link VivifyingMap}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
import javax.lang.model.element.AnnotationMirror;
import javax.lang.model.element.Element;
import javax.lang.model.element.VariableElement;
import org.checkerframework.checker.mustcall.qual.MustCall;
import org.checkerframework.dataflow.cfg.node.MethodInvocationNode;
import org.checkerframework.dataflow.cfg.visualize.CFGVisualizer;
import org.checkerframework.dataflow.expression.ClassName;
Expand All @@ -28,10 +29,14 @@
* A store that extends {@code CFAbstractStore} and additionally tracks which fields of the 'self'
* reference have been initialized.
*
* @param <V> the type of values in the abstract store
* @param <S> the type of the abstract store
* @see InitializationTransfer
*/
public class InitializationStore<V extends CFAbstractValue<V>, S extends InitializationStore<V, S>>
extends CFAbstractStore<V, S> {
public class InitializationStore<
V extends CFAbstractValue<@MustCall({}) V>,
S extends InitializationStore<@MustCall({}) V, @MustCall({}) S>>
extends CFAbstractStore<@MustCall({}) V, @MustCall({}) S> {

/** The set of fields that are initialized. */
protected final Set<VariableElement> initializedFields;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@
import javax.lang.model.type.TypeKind;
import javax.lang.model.type.TypeMirror;
import javax.lang.model.util.ElementFilter;
import org.checkerframework.checker.mustcall.qual.MustCall;
import org.checkerframework.dataflow.analysis.RegularTransferResult;
import org.checkerframework.dataflow.analysis.TransferInput;
import org.checkerframework.dataflow.analysis.TransferResult;
Expand Down Expand Up @@ -58,7 +59,7 @@
public class InitializationTransfer<
V extends CFAbstractValue<V>,
T extends InitializationTransfer<V, T, S>,
S extends InitializationStore<V, S>>
S extends InitializationStore<@MustCall({}) V, @MustCall({}) S>>
extends CFAbstractTransfer<V, S, T> {

protected final InitializationAnnotatedTypeFactory<?, ?, ?, ?> atypeFactory;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -352,7 +352,7 @@ public boolean derivedFromMustCallAlias() {
}

/**
* Gets the must-call type associated with the given resource alias, falling on back on the
* Gets the must-call type associated with the given resource alias, falling back on the
* declared type if there is no refined type for the alias in the store.
*
* @param alias a resource alias
Expand All @@ -366,7 +366,9 @@ private static AnnotationMirror getMustCallValue(
CFValue value = mcStore == null ? null : mcStore.getValue(reference);
if (value != null) {
AnnotationMirror result =
AnnotationUtils.getAnnotationByClass(value.getAnnotations(), MustCall.class);
mcAtf
.getQualifierHierarchy()
.findAnnotationInHierarchy(value.getAnnotations(), mcAtf.TOP);
if (result != null) {
return result;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
* Demonstrates an issue in the Checker Framework with handling the nearest enclosing element for
* temporary variable declarations, leading to a crash during analysis.
*/
@SuppressWarnings("all") // only check for crashes
public abstract class CrashForTempVar<T extends Number> {

private final CrashForTempVar<T> _base;
Expand Down
15 changes: 15 additions & 0 deletions checker/tests/resourceleak/DropOwning.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
// test case for https://github.com/typetools/checker-framework/issues/6990

import java.io.Closeable;
import org.checkerframework.checker.mustcall.qual.MustCallUnknown;
import org.checkerframework.checker.mustcall.qual.Owning;

public class DropOwning {

public void f(@Owning Closeable resource) {
drop(resource);
}

// :: error: required.method.not.known
private void drop(@Owning @MustCallUnknown Object resourceCF6990) {}
}
Loading