Class UnitThrowAnalysis

  • All Implemented Interfaces:
    ThrowAnalysis
    Direct Known Subclasses:
    DalvikThrowAnalysis, DotnetThrowAnalysis

    public class UnitThrowAnalysis
    extends AbstractThrowAnalysis
    A ThrowAnalysis which returns the set of runtime exceptions and errors that might be thrown by the bytecode instructions represented by a unit, as indicated by the Java Virtual Machine specification. I.e. this analysis is based entirely on the “opcode” of the unit, the types of its arguments, and the values of constant arguments.

    The mightThrow methods could be declared static. They are left virtual to facilitate testing. For example, to verify that the expressions in a method call are actually being examined, a test case can override the mightThrow(SootMethod) with an implementation which returns the empty set instead of all possible exceptions.

    • Constructor Detail

      • UnitThrowAnalysis

        public UnitThrowAnalysis​(Singletons.Global g)
        Constructs a UnitThrowAnalysis for inclusion in Soot's global variable manager, G.
        Parameters:
        g - guarantees that the constructor may only be called from Singletons.
      • UnitThrowAnalysis

        protected UnitThrowAnalysis()
        A protected constructor for use by unit tests.
      • UnitThrowAnalysis

        protected UnitThrowAnalysis​(boolean isInterproc)
    • Method Detail

      • v

        public static UnitThrowAnalysis v()
        Returns the single instance of UnitThrowAnalysis.
        Returns:
        Soot's UnitThrowAnalysis.
      • mightThrowImplicitly

        public ThrowableSet mightThrowImplicitly​(ThrowInst t)
        Description copied from interface: ThrowAnalysis
        Returns a set representing the Throwable types that the specified throw instruction might throw implicitly, that is, the possible types of errors which might arise in the course of executing the throw instruction, rather than the type of the throw's operand.
        Specified by:
        mightThrowImplicitly in interface ThrowAnalysis
        Specified by:
        mightThrowImplicitly in class AbstractThrowAnalysis
        Parameters:
        t - ThrowStmt whose implicit exceptions are to be returned.
        Returns:
        a representation of the types of exceptions that t might throw implicitly.
      • mightThrowImplicitly

        public ThrowableSet mightThrowImplicitly​(ThrowStmt t)
        Description copied from interface: ThrowAnalysis
        Returns a set representing the Throwable types that the specified throw statement might throw implicitly, that is, the possible types of errors which might arise in the course of executing the throw statement, rather than the type of the throw's operand.
        Specified by:
        mightThrowImplicitly in interface ThrowAnalysis
        Specified by:
        mightThrowImplicitly in class AbstractThrowAnalysis
        Parameters:
        t - ThrowStmt whose implicit exceptions are to be returned.
        Returns:
        a representation of the types of exceptions that t might throw implicitly.
      • mightThrow

        public ThrowableSet mightThrow​(SootMethod sm)
        Returns the set of types that might be thrown as a result of calling the specified method.
        Parameters:
        sm - method whose exceptions are to be returned.
        Returns:
        a representation of the set of Throwable types that m might throw.
      • mightThrow

        protected ThrowableSet mightThrow​(SootMethod sm,
                                          Set<SootMethod> doneSet)
        Returns the set of types that might be thrown as a result of calling the specified method.
        Parameters:
        sm - method whose exceptions are to be returned.
        doneSet - The set of methods that were already processed
        Returns:
        a representation of the set of Throwable types that m might throw.
      • mightThrow

        protected ThrowableSet mightThrow​(SootMethod sm,
                                          Set<SootMethod> doneSet,
                                          int depth)
        Returns the set of types that might be thrown as a result of calling the specified method.
        Parameters:
        sm - method whose exceptions are to be returned.
        doneSet - The set of methods that were already processed
        depth - The maximum depth to use
        Returns:
        a representation of the set of Throwable types that m might throw.