Class StateSet
java.lang.Object
edu.umd.cs.findbugs.ba.obl.StateSet
A dataflow fact used in ObligationAnalysis. It is a set of State objects,
plus the additional capability to represent top and bottom elements.
Invariant: no StateSet may contain more than one State with the same ObligationSet.
See Weimer and Necula, Finding and preventing run-time error handling mistakes, OOPSLA 2004.
-
Field Summary
FieldsModifier and TypeFieldDescriptionprivate final ObligationFactoryprivate booleanprivate booleanprivate booleanprivate Map<ObligationSet, State> -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionvoidaddObligation(Obligation obligation, int basicBlockId) Add an obligation to every State in the StateSet.private voidcheckCircularity(State state, Obligation obligation, int basicBlockId) Bail out of the analysis is an obligation is acquired or released in a loop.voidclear()voidMake this StateSet an exact copy of the given StateSet.Return a newly allocated Map of ObligationSet to State that may be passed to applyToAllStatesAndUpdateMap().voiddeleteObligation(Obligation obligation, int basicBlockId) Remove an Obligation from every State in the StateSet.Return an exact deep copy of this StateSet.booleanGet Set of all ObligationsSets in this StateSet.getPrefixStates(Path path) Get all States that have Paths which are prefixes of the given Path.getStateWithObligationSet(ObligationSet obligationSet) Get the State which has the given ObligationSet.inthashCode()booleanisBottom()booleanisEmpty()booleanbooleanisTop()booleanisValid()voidreplaceMap(Map<ObligationSet, State> stateMap) Replace the map of ObligationSets to States with the given one.voidvoidsetOnExceptionPath(boolean onExceptionPath) voidsetTop()Return an Iterator over the States in the StateSet.toString()
-
Field Details
-
isTop
private boolean isTop -
isBottom
private boolean isBottom -
onExceptionPath
private boolean onExceptionPath -
stateMap
-
factory
-
-
Constructor Details
-
StateSet
-
-
Method Details
-
isEmpty
public boolean isEmpty() -
setTop
public void setTop() -
isTop
public boolean isTop() -
setBottom
public void setBottom() -
isBottom
public boolean isBottom() -
isValid
public boolean isValid() -
isOnExceptionPath
public boolean isOnExceptionPath() -
setOnExceptionPath
public void setOnExceptionPath(boolean onExceptionPath) -
clear
public void clear() -
stateIterator
-
getAllObligationSets
Get Set of all ObligationsSets in this StateSet.- Returns:
- Set of all ObligationsSets in this StateSet
-
getStateWithObligationSet
Get the State which has the given ObligationSet. Returns null if there is no such state.- Parameters:
obligationSet- we want to get the State with this ObligationSet- Returns:
- the State with the given ObligationSet, or null if there is no such State
-
copyFrom
Make this StateSet an exact copy of the given StateSet.- Parameters:
other- a StateSet; this StateSet will be made identical to it
-
duplicate
Return an exact deep copy of this StateSet.- Returns:
- an exact deep copy of this StateSet
-
addObligation
public void addObligation(Obligation obligation, int basicBlockId) throws ObligationAcquiredOrReleasedInLoopException Add an obligation to every State in the StateSet.- Parameters:
obligation- the obligation to addbasicBlockId- the id of the basic block (path component) adding the obligation- Throws:
ObligationAcquiredOrReleasedInLoopException
-
deleteObligation
public void deleteObligation(Obligation obligation, int basicBlockId) throws ObligationAcquiredOrReleasedInLoopException Remove an Obligation from every State in the StateSet.- Parameters:
obligation- the obligation to removebasicBlockId- the id of the basic block (path component) removing the obligation- Throws:
ObligationAcquiredOrReleasedInLoopException
-
checkCircularity
private void checkCircularity(State state, Obligation obligation, int basicBlockId) throws ObligationAcquiredOrReleasedInLoopException Bail out of the analysis is an obligation is acquired or released in a loop.- Parameters:
state- a State to which an obligation is being added or removedobligation- the Obligation being added or removedbasicBlockId- the id of the BasicBlock adding or removing the obligation- Throws:
ObligationAcquiredOrReleasedInLoopException
-
replaceMap
Replace the map of ObligationSets to States with the given one.- Parameters:
stateMap- enw map of ObligationSets to States
-
getPrefixStates
-
equals
-
hashCode
-
toString
-
createEmptyMap
Return a newly allocated Map of ObligationSet to State that may be passed to applyToAllStatesAndUpdateMap().
-