Class ClassicCompleteUnitGraph

  • All Implemented Interfaces:
    Iterable<Unit>, DirectedBodyGraph<Unit>, DirectedGraph<Unit>

    public class ClassicCompleteUnitGraph
    extends TrapUnitGraph

    Represents a CFG for a Body instance where the nodes are Unit instances, and where edges are a conservative indication of unexceptional and exceptional control flow.

    ClassicCompleteUnitGraph attempts to duplicate the results that would have been produced by Soot's CompleteUnitGraph in releases up to Soot 2.1.0 (the one known discrepancy is that the 2.1.0 CompleteUnitGraph would include two edges joining one node to another Units if the first node both branched to and fell through to the second). It is included solely for testing purposes, and should not be used in actual analyses.

    There are two distinctions between the graphs produced by the ClassicCompleteUnitGraph and ExceptionalUnitGraph:

    1. ExceptionalUnitGraph only creates edges to a Trap handler for trapped Units that have the potential to throw the particular exception type caught by the handler, according to the ThrowAnalysis used to estimate which exceptions each Unit may throw. ClassicCompleteUnitGraph creates edges for all trapped Units, regardless of the types of exceptions they may throw.
    2. When ExceptionalUnitGraph creates edges for a trapped Unit that may throw a caught exception, it adds edges from each predecessor of the excepting Unit to the handler. If the excepting Unit itself has no potential side effects, ExceptionalUnitGraph may omit an edge from it to the handler, depending on the parameters passed to the ExceptionalUnitGraph constructor. ClassicCompleteUnitGraph, on the other hand, always adds an edge from the excepting Unit itself to the handler, and adds edges from the predecessor only of the first Unit covered by a Trap (in this one aspect ClassicCompleteUnitGraph is less conservative than ExceptionalUnitGraph, since it ignores the possibility of a branch into the middle of a protected area).

    • Constructor Detail

      • ClassicCompleteUnitGraph

        public ClassicCompleteUnitGraph​(Body body)
        Constructs the graph from a given Body instance.
        Parameters:
        body - the Body instance from which the graph is built.
    • Method Detail

      • buildExceptionalEdges

        protected void buildExceptionalEdges​(Map<Unit,​List<Unit>> unitToSuccs,
                                             Map<Unit,​List<Unit>> unitToPreds)
        Method to compute the edges corresponding to exceptional control flow.
        Overrides:
        buildExceptionalEdges in class TrapUnitGraph
        Parameters:
        unitToSuccs - A Map from Units to Lists of Units. This is * an ``out parameter''; buildExceptionalEdges will add a mapping for every Unit within the scope of one or more Traps to a List of the handler units of those Traps.
        unitToPreds - A Map from Units to Lists of Units. This is an ``out parameter''; buildExceptionalEdges will add a mapping for every Trap handler to all the Units within the scope of that Trap.