Class NullnessAnalysis
- java.lang.Object
-
- soot.toolkits.scalar.AbstractFlowAnalysis<N,A>
-
- soot.toolkits.scalar.BranchedFlowAnalysis<Unit,A>
-
- soot.toolkits.scalar.ForwardBranchedFlowAnalysis<NullnessAnalysis.AnalysisInfo>
-
- soot.jimple.toolkits.annotation.nullcheck.NullnessAnalysis
-
public class NullnessAnalysis extends ForwardBranchedFlowAnalysis<NullnessAnalysis.AnalysisInfo>
An intraprocedural nullness analysis that computes for each location and each value in a method if the value is (before or after that location) definitely null, definitely non-null or neither. This class replacesBranchedRefVarsAnalysiswhich is known to have bugs.- Author:
- Eric Bodden, Julian Tibble
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description protected classNullnessAnalysis.AnalysisInfoThe analysis info is a simple mapping of typeValueto any of the constants BOTTOM, NON_NULL, NULL or TOP.
-
Field Summary
Fields Modifier and Type Field Description protected static intBOTTOMprotected static intNON_NULLprotected static intNULLprotected static intTOPprotected intusedprotected HashMap<Value,Integer>valueToIndex-
Fields inherited from class soot.toolkits.scalar.BranchedFlowAnalysis
unitToAfterBranchFlow, unitToAfterFallFlow
-
Fields inherited from class soot.toolkits.scalar.AbstractFlowAnalysis
filterUnitToBeforeFlow, graph, unitToBeforeFlow
-
-
Constructor Summary
Constructors Constructor Description NullnessAnalysis(UnitGraph graph)Creates a new analysis for the given graph/
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description protected voidcopy(NullnessAnalysis.AnalysisInfo s, NullnessAnalysis.AnalysisInfo d)Creates a copy of thesourceflow object indest.protected voidflowThrough(NullnessAnalysis.AnalysisInfo in, Unit u, List<NullnessAnalysis.AnalysisInfo> fallOut, List<NullnessAnalysis.AnalysisInfo> branchOuts)Given the merge of theinsets, compute thefallOutandbranchOutsset fors.protected booleanisAlwaysNonNull(Value v)This can be overwritten by subclasses to mark a certain value as constantly non-null.booleanisAlwaysNonNullBefore(Unit s, Immediate i)Returnstrueif the analysis could determine that i is always non-null before the statement s.booleanisAlwaysNullBefore(Unit s, Immediate i)Returnstrueif the analysis could determine that i is always null before the statement s.protected voidmerge(NullnessAnalysis.AnalysisInfo in1, NullnessAnalysis.AnalysisInfo in2, NullnessAnalysis.AnalysisInfo out)Compute the merge of thein1andin2sets, putting the result intoout.protected NullnessAnalysis.AnalysisInfonewInitialFlow()Returns the flow object corresponding to the initial values for each graph node.-
Methods inherited from class soot.toolkits.scalar.ForwardBranchedFlowAnalysis
doAnalysis, isForward
-
Methods inherited from class soot.toolkits.scalar.BranchedFlowAnalysis
getBranchFlowAfter, getFallFlowAfter
-
Methods inherited from class soot.toolkits.scalar.AbstractFlowAnalysis
entryInitialFlow, getFlowBefore, merge, mergeInto, treatTrapHandlersAsEntries
-
-
-
-
Field Detail
-
BOTTOM
protected static final int BOTTOM
- See Also:
- Constant Field Values
-
NULL
protected static final int NULL
- See Also:
- Constant Field Values
-
NON_NULL
protected static final int NON_NULL
- See Also:
- Constant Field Values
-
TOP
protected static final int TOP
- See Also:
- Constant Field Values
-
used
protected int used
-
-
Constructor Detail
-
NullnessAnalysis
public NullnessAnalysis(UnitGraph graph)
Creates a new analysis for the given graph/- Parameters:
graph- any unit graph
-
-
Method Detail
-
flowThrough
protected void flowThrough(NullnessAnalysis.AnalysisInfo in, Unit u, List<NullnessAnalysis.AnalysisInfo> fallOut, List<NullnessAnalysis.AnalysisInfo> branchOuts)
Given the merge of theinsets, compute thefallOutandbranchOutsset fors.- Specified by:
flowThroughin classBranchedFlowAnalysis<Unit,NullnessAnalysis.AnalysisInfo>
-
isAlwaysNonNull
protected boolean isAlwaysNonNull(Value v)
This can be overwritten by subclasses to mark a certain value as constantly non-null.- Parameters:
v- any value- Returns:
- true if it is known that this value (e.g. a method return value) is never null
-
copy
protected void copy(NullnessAnalysis.AnalysisInfo s, NullnessAnalysis.AnalysisInfo d)
Creates a copy of thesourceflow object indest.- Specified by:
copyin classAbstractFlowAnalysis<Unit,NullnessAnalysis.AnalysisInfo>
-
merge
protected void merge(NullnessAnalysis.AnalysisInfo in1, NullnessAnalysis.AnalysisInfo in2, NullnessAnalysis.AnalysisInfo out)
Compute the merge of thein1andin2sets, putting the result intoout. The behavior of this function depends on the implementation ( it may be necessary to check whetherin1andin2are equal or aliased ). Used by the doAnalysis method.- Specified by:
mergein classAbstractFlowAnalysis<Unit,NullnessAnalysis.AnalysisInfo>
-
newInitialFlow
protected NullnessAnalysis.AnalysisInfo newInitialFlow()
Returns the flow object corresponding to the initial values for each graph node.- Specified by:
newInitialFlowin classAbstractFlowAnalysis<Unit,NullnessAnalysis.AnalysisInfo>
-
isAlwaysNullBefore
public boolean isAlwaysNullBefore(Unit s, Immediate i)
Returnstrueif the analysis could determine that i is always null before the statement s.- Parameters:
s- a statement of the respective bodyi- a local or constant of that body- Returns:
- true if i is always null right before this statement
-
isAlwaysNonNullBefore
public boolean isAlwaysNonNullBefore(Unit s, Immediate i)
Returnstrueif the analysis could determine that i is always non-null before the statement s.- Parameters:
s- a statement of the respective bodyi- a local of that body- Returns:
- true if i is always non-null right before this statement
-
-