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

org.checkerframework.dataflow.cfg.builder.TryFinallyScopeMap 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.checkerframework.checker.nullness.qual.Nullable;
import org.plumelib.util.ArrayMap;

import java.util.HashMap;
import java.util.Map;

import javax.lang.model.element.Name;

/**
 * A map that keeps track of new labels added within a try block. For names that are outside of the
 * try block, the finally label is returned. This ensures that a finally block is executed when
 * control flows outside of the try block.
 */
@SuppressWarnings("serial")
/*package-private*/ class TryFinallyScopeMap extends HashMap {
    /** New labels within a try block that were added by this implementation. */
    private final Map accessedNames;

    /** Create a new TryFinallyScopeMap. */
    protected TryFinallyScopeMap() {
        this.accessedNames = new ArrayMap<>(2);
    }

    @Override
    public Label get(@Nullable Object key) {
        if (key == null) {
            throw new IllegalArgumentException();
        }
        if (super.containsKey(key)) {
            return super.get(key);
        } else {
            if (accessedNames.containsKey(key)) {
                return accessedNames.get(key);
            }
            Label l = new Label();
            accessedNames.put((Name) key, l);
            return l;
        }
    }

    @Override
    @SuppressWarnings(
            "keyfor:contracts.conditional.postcondition.not.satisfied") // get adds everything
    public boolean containsKey(@Nullable Object key) {
        return true;
    }

    public Map getAccessedNames() {
        return accessedNames;
    }
}




© 2015 - 2025 Weber Informatics LLC | Privacy Policy