Search in sources :

Example 16 with Nullable

use of org.checkerframework.checker.nullness.qual.Nullable in project universa by UniversaBlockchain.

the class UnikeyFactory method rsaOaepPKFromUnikey.

/**
 * Given the .unikey-format byte array with the private key, create the {@link RSAOAEPPrivateKey}.
 */
@Nullable
static RSAOAEPPrivateKey rsaOaepPKFromUnikey(@NonNull byte[] bytes) {
    assert bytes != null;
    try {
        final ArrayList unpackedFromBoss = Boss.load(bytes);
        assert ((Integer) unpackedFromBoss.get(0)) == 0;
        final byte[] e = ((Bytes) unpackedFromBoss.get(1)).toArray(), p = ((Bytes) unpackedFromBoss.get(2)).toArray(), q = ((Bytes) unpackedFromBoss.get(3)).toArray();
        return new RSAOAEPPrivateKey(e, p, q, RSAOAEPPrivateKey.DEFAULT_OAEP_HASH, RSAOAEPPrivateKey.DEFAULT_MGF1_HASH, new SecureRandom());
    } catch (Throwable e) {
        return null;
    }
}
Also used : Bytes(net.sergeych.utils.Bytes) ArrayList(java.util.ArrayList) SecureRandom(java.security.SecureRandom) Nullable(org.checkerframework.checker.nullness.qual.Nullable)

Example 17 with Nullable

use of org.checkerframework.checker.nullness.qual.Nullable in project checker-framework by typetools.

the class Analysis method getValue.

/**
 * @return the abstract value for {@link Tree} {@code t}, or {@code null} if no information is
 *     available. Note that if the analysis has not finished yet, this value might not represent
 *     the final value for this node.
 */
@Nullable
public A getValue(Tree t) {
    // we do not yet have a org.checkerframework.dataflow fact about the current node
    if (t == currentTree) {
        return null;
    }
    Set<Node> nodesCorrespondingToTree = getNodesForTree(t);
    if (nodesCorrespondingToTree == null) {
        return null;
    }
    A merged = null;
    for (Node aNode : nodesCorrespondingToTree) {
        if (aNode.isLValue()) {
            return null;
        }
        A a = getValue(aNode);
        if (merged == null) {
            merged = a;
        } else if (a != null) {
            merged = merged.leastUpperBound(a);
        }
    }
    return merged;
}
Also used : AssignmentNode(org.checkerframework.dataflow.cfg.node.AssignmentNode) ReturnNode(org.checkerframework.dataflow.cfg.node.ReturnNode) LocalVariableNode(org.checkerframework.dataflow.cfg.node.LocalVariableNode) Node(org.checkerframework.dataflow.cfg.node.Node) Nullable(org.checkerframework.checker.nullness.qual.Nullable)

Example 18 with Nullable

use of org.checkerframework.checker.nullness.qual.Nullable in project checker-framework by typetools.

the class AnalysisResult method getValue.

/**
 * @return the abstract value for {@link Tree} {@code t}, or {@code null} if no information is
 *     available.
 */
@Nullable
public A getValue(Tree t) {
    Set<Node> nodes = treeLookup.get(t);
    if (nodes == null) {
        return null;
    }
    if (nodes.size() == 1) {
        Node aNode = nodes.iterator().next();
        A val = getValue(aNode);
        return val;
    } else {
        A merged = null;
        for (Node aNode : nodes) {
            A a = getValue(aNode);
            if (merged == null) {
                merged = a;
            } else if (a != null) {
                merged = merged.leastUpperBound(a);
            }
        }
        return merged;
    }
}
Also used : AssignmentNode(org.checkerframework.dataflow.cfg.node.AssignmentNode) Node(org.checkerframework.dataflow.cfg.node.Node) Nullable(org.checkerframework.checker.nullness.qual.Nullable)

Example 19 with Nullable

use of org.checkerframework.checker.nullness.qual.Nullable in project checker-framework by typetools.

the class DOTCFGVisualizer method visualize.

/**
 * {@inheritDoc}
 */
@Override
@Nullable
public Map<String, Object> visualize(ControlFlowGraph cfg, Block entry, @Nullable Analysis<A, S, T> analysis) {
    String dotgraph = generateDotGraph(cfg, entry, analysis);
    String dotfilename = dotOutputFileName(cfg.underlyingAST);
    try {
        FileWriter fstream = new FileWriter(dotfilename);
        BufferedWriter out = new BufferedWriter(fstream);
        out.write(dotgraph);
        out.close();
    } catch (IOException e) {
        ErrorReporter.errorAbort("Error creating dot file: " + dotfilename + "; ensure the path is valid", e);
    }
    Map<String, Object> res = new HashMap<>();
    res.put("dotFileName", dotfilename);
    return res;
}
Also used : HashMap(java.util.HashMap) IdentityHashMap(java.util.IdentityHashMap) FileWriter(java.io.FileWriter) IOException(java.io.IOException) BufferedWriter(java.io.BufferedWriter) Nullable(org.checkerframework.checker.nullness.qual.Nullable)

Example 20 with Nullable

use of org.checkerframework.checker.nullness.qual.Nullable in project checker-framework by typetools.

the class SourceChecker method isAnnotatedForThisCheckerOrUpstreamChecker.

private boolean isAnnotatedForThisCheckerOrUpstreamChecker(@Nullable Element elt) {
    if (elt == null || !useUncheckedCodeDefault("source")) {
        return false;
    }
    @Nullable AnnotatedFor anno = elt.getAnnotation(AnnotatedFor.class);
    String[] userAnnotatedFors = (anno == null ? null : anno.value());
    if (userAnnotatedFors != null) {
        List<String> upstreamCheckerNames = getUpstreamCheckerNames();
        for (String userAnnotatedFor : userAnnotatedFors) {
            if (CheckerMain.matchesCheckerOrSubcheckerFromList(userAnnotatedFor, upstreamCheckerNames)) {
                return true;
            }
        }
    }
    return false;
}
Also used : Nullable(org.checkerframework.checker.nullness.qual.Nullable) AnnotatedFor(org.checkerframework.framework.qual.AnnotatedFor)

Aggregations

Nullable (org.checkerframework.checker.nullness.qual.Nullable)27 TypeElement (javax.lang.model.element.TypeElement)7 VariableElement (javax.lang.model.element.VariableElement)4 TreePath (com.sun.source.util.TreePath)3 Method (java.lang.reflect.Method)3 ReentrantLock (java.util.concurrent.locks.ReentrantLock)3 Element (javax.lang.model.element.Element)3 ClassTree (com.sun.source.tree.ClassTree)2 MethodTree (com.sun.source.tree.MethodTree)2 VariableTree (com.sun.source.tree.VariableTree)2 ExecutableElement (javax.lang.model.element.ExecutableElement)2 PackageElement (javax.lang.model.element.PackageElement)2 Prefix (org.checkerframework.checker.units.qual.Prefix)2 AssignmentNode (org.checkerframework.dataflow.cfg.node.AssignmentNode)2 Node (org.checkerframework.dataflow.cfg.node.Node)2 Pure (org.checkerframework.dataflow.qual.Pure)2 AnnotationBuilder (org.checkerframework.javacutil.AnnotationBuilder)2 AnnotationTree (com.sun.source.tree.AnnotationTree)1 AssignmentTree (com.sun.source.tree.AssignmentTree)1 BlockTree (com.sun.source.tree.BlockTree)1