Package soot.toolkits.exceptions
Class UnitThrowAnalysis
- java.lang.Object
-
- soot.toolkits.exceptions.AbstractThrowAnalysis
-
- soot.toolkits.exceptions.UnitThrowAnalysis
-
- All Implemented Interfaces:
ThrowAnalysis
- Direct Known Subclasses:
DalvikThrowAnalysis,DotnetThrowAnalysis
public class UnitThrowAnalysis extends AbstractThrowAnalysis
AThrowAnalysiswhich 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
mightThrowmethods 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.
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description protected classUnitThrowAnalysis.UnitSwitchprotected classUnitThrowAnalysis.ValueSwitch
-
Field Summary
Fields Modifier and Type Field Description static UnitThrowAnalysisinterproceduralAnalysisprotected booleanisInterprocprotected com.google.common.cache.LoadingCache<SootMethod,ThrowableSet>methodToThrowSetprotected ThrowableSet.Managermgr
-
Constructor Summary
Constructors Modifier Constructor Description protectedUnitThrowAnalysis()A protected constructor for use by unit tests.protectedUnitThrowAnalysis(boolean isInterproc)UnitThrowAnalysis(Singletons.Global g)Constructs aUnitThrowAnalysisfor inclusion in Soot's global variable manager,G.
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description protected ThrowableSetdefaultResult()static UnitThrowAnalysisinterproc()ThrowableSetmightThrow(SootMethod sm)Returns the set of types that might be thrown as a result of calling the specified method.ThrowableSetmightThrow(SootMethodRef m)ThrowableSetmightThrow(Unit u)Returns a set representing theThrowabletypes that the specified unit might throw.ThrowableSetmightThrow(Unit u, SootMethod sm)protected ThrowableSetmightThrow(Value v)ThrowableSetmightThrowImplicitly(ThrowInst t)Returns a set representing theThrowabletypes that the specified throw instruction might throw implicitly, that is, the possible types of errors which might arise in the course of executing thethrowinstruction, rather than the type of thethrow's operand.ThrowableSetmightThrowImplicitly(ThrowStmt t)Returns a set representing theThrowabletypes that the specified throw statement might throw implicitly, that is, the possible types of errors which might arise in the course of executing thethrowstatement, rather than the type of thethrow's operand.protected UnitThrowAnalysis.UnitSwitchunitSwitch(SootMethod sm)static UnitThrowAnalysisv()Returns the single instance ofUnitThrowAnalysis.protected UnitThrowAnalysis.ValueSwitchvalueSwitch()-
Methods inherited from class soot.toolkits.exceptions.AbstractThrowAnalysis
mightThrowExplicitly, mightThrowExplicitly, mightThrowExplicitly
-
-
-
-
Field Detail
-
mgr
protected final ThrowableSet.Manager mgr
-
isInterproc
protected final boolean isInterproc
-
interproceduralAnalysis
public static UnitThrowAnalysis interproceduralAnalysis
-
methodToThrowSet
protected final com.google.common.cache.LoadingCache<SootMethod,ThrowableSet> methodToThrowSet
-
-
Constructor Detail
-
UnitThrowAnalysis
public UnitThrowAnalysis(Singletons.Global g)
Constructs aUnitThrowAnalysisfor inclusion in Soot's global variable manager,G.- Parameters:
g- guarantees that the constructor may only be called fromSingletons.
-
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 ofUnitThrowAnalysis.- Returns:
- Soot's
UnitThrowAnalysis.
-
interproc
public static UnitThrowAnalysis interproc()
-
defaultResult
protected ThrowableSet defaultResult()
-
unitSwitch
protected UnitThrowAnalysis.UnitSwitch unitSwitch(SootMethod sm)
-
valueSwitch
protected UnitThrowAnalysis.ValueSwitch valueSwitch()
-
mightThrow
public ThrowableSet mightThrow(Unit u)
Description copied from interface:ThrowAnalysisReturns a set representing theThrowabletypes that the specified unit might throw.- Specified by:
mightThrowin interfaceThrowAnalysis- Specified by:
mightThrowin classAbstractThrowAnalysis- Parameters:
u-Unitwhose exceptions are to be returned.- Returns:
- a representation of the
Throwabletypes thatumight throw.
-
mightThrow
public ThrowableSet mightThrow(Unit u, SootMethod sm)
-
mightThrowImplicitly
public ThrowableSet mightThrowImplicitly(ThrowInst t)
Description copied from interface:ThrowAnalysisReturns a set representing theThrowabletypes that the specified throw instruction might throw implicitly, that is, the possible types of errors which might arise in the course of executing thethrowinstruction, rather than the type of thethrow's operand.- Specified by:
mightThrowImplicitlyin interfaceThrowAnalysis- Specified by:
mightThrowImplicitlyin classAbstractThrowAnalysis- Parameters:
t-ThrowStmtwhose implicit exceptions are to be returned.- Returns:
- a representation of the types of exceptions that
tmight throw implicitly.
-
mightThrowImplicitly
public ThrowableSet mightThrowImplicitly(ThrowStmt t)
Description copied from interface:ThrowAnalysisReturns a set representing theThrowabletypes that the specified throw statement might throw implicitly, that is, the possible types of errors which might arise in the course of executing thethrowstatement, rather than the type of thethrow's operand.- Specified by:
mightThrowImplicitlyin interfaceThrowAnalysis- Specified by:
mightThrowImplicitlyin classAbstractThrowAnalysis- Parameters:
t-ThrowStmtwhose implicit exceptions are to be returned.- Returns:
- a representation of the types of exceptions that
tmight throw implicitly.
-
mightThrow
protected ThrowableSet mightThrow(Value v)
-
mightThrow
public ThrowableSet mightThrow(SootMethodRef m)
-
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
Throwabletypes thatmmight throw.
-
-