edu.umd.cs.findbugs.ba.npe
Class IsNullValueAnalysis

java.lang.Object
  extended by edu.umd.cs.findbugs.ba.AbstractDataflowAnalysis<Fact>
      extended by edu.umd.cs.findbugs.ba.ForwardDataflowAnalysis<FrameType>
          extended by edu.umd.cs.findbugs.ba.FrameDataflowAnalysis<IsNullValue,IsNullValueFrame>
              extended by edu.umd.cs.findbugs.ba.npe.IsNullValueAnalysis
All Implemented Interfaces:
DataflowAnalysis<IsNullValueFrame>, EdgeTypes, IsNullValueAnalysisFeatures

public class IsNullValueAnalysis
extends FrameDataflowAnalysis<IsNullValue,IsNullValueFrame>
implements EdgeTypes, IsNullValueAnalysisFeatures

A dataflow analysis to detect potential null pointer dereferences.

Author:
David Hovemeyer
See Also:
IsNullValue, IsNullValueFrame, IsNullValueFrameModelingVisitor

Field Summary
 
Fields inherited from interface edu.umd.cs.findbugs.ba.EdgeTypes
BACKEDGE_SOURCE_EDGE, BACKEDGE_TARGET_EDGE, CHECKED_EXCEPTIONS_FLAG, EXIT_EDGE, EXPLICIT_EXCEPTIONS_FLAG, FALL_THROUGH_EDGE, GOTO_EDGE, HANDLED_EXCEPTION_EDGE, IFCMP_EDGE, JSR_EDGE, RET_EDGE, RETURN_EDGE, START_EDGE, SWITCH_DEFAULT_EDGE, SWITCH_EDGE, UNHANDLED_EXCEPTION_EDGE, UNKNOWN_EDGE
 
Fields inherited from interface edu.umd.cs.findbugs.ba.npe.IsNullValueAnalysisFeatures
NCP_EXTRA_BRANCH, NO_SPLIT_DOWNGRADE_NSP, NO_SWITCH_DEFAULT_AS_EXCEPTION, UNKNOWN_VALUES_ARE_NSP
 
Constructor Summary
IsNullValueAnalysis(org.apache.bcel.generic.MethodGen methodGen, CFG cfg, ValueNumberDataflow vnaDataflow, DepthFirstSearch dfs, AssertionMethods assertionMethods)
           
 
Method Summary
 IsNullValueFrame createFact()
          Create empty (uninitialized) dataflow facts for one program point.
 void endTransfer(BasicBlock basicBlock, org.apache.bcel.generic.InstructionHandle end, java.lang.Object result_)
          Subclasses may override this.
 JavaClassAndMethod getClassAndMethod()
           
 void initEntryFact(IsNullValueFrame result)
          Initialize the "entry" fact for the graph.
static void main(java.lang.String[] argv)
          Test driver.
 void meetInto(IsNullValueFrame fact, Edge edge, IsNullValueFrame result)
          Meet a dataflow fact associated with an incoming edge into another fact.
protected  void mergeValues(IsNullValueFrame otherFrame, IsNullValueFrame resultFrame, int slot)
          Merge the values contained in a given slot of two Frames.
 void setClassAndMethod(JavaClassAndMethod classAndMethod)
           
 void startTransfer(BasicBlock basicBlock, java.lang.Object start_)
          Subclasses may override this.
 void transfer(BasicBlock basicBlock, org.apache.bcel.generic.InstructionHandle end, IsNullValueFrame start, IsNullValueFrame result)
          Transfer function for the analysis.
 void transferInstruction(org.apache.bcel.generic.InstructionHandle handle, BasicBlock basicBlock, IsNullValueFrame fact)
          Transfer function for a single instruction.
 
Methods inherited from class edu.umd.cs.findbugs.ba.FrameDataflowAnalysis
copy, initResultFact, isFactValid, makeFactTop, mergeInto, modifyFrame, same
 
Methods inherited from class edu.umd.cs.findbugs.ba.ForwardDataflowAnalysis
getBlockOrder, getDepthFirstSearch, isForwards
 
Methods inherited from class edu.umd.cs.findbugs.ba.AbstractDataflowAnalysis
factToString, getFactAfterLocation, getFactAtLocation, getResultFact, getStartFact, resultFactIterator
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

IsNullValueAnalysis

public IsNullValueAnalysis(org.apache.bcel.generic.MethodGen methodGen,
                           CFG cfg,
                           ValueNumberDataflow vnaDataflow,
                           DepthFirstSearch dfs,
                           AssertionMethods assertionMethods)
Method Detail

setClassAndMethod

public void setClassAndMethod(JavaClassAndMethod classAndMethod)

getClassAndMethod

public JavaClassAndMethod getClassAndMethod()

createFact

public IsNullValueFrame createFact()
Description copied from interface: DataflowAnalysis
Create empty (uninitialized) dataflow facts for one program point. A valid value will be copied into it before it is used.

Specified by:
createFact in interface DataflowAnalysis<IsNullValueFrame>

initEntryFact

public void initEntryFact(IsNullValueFrame result)
Description copied from interface: DataflowAnalysis
Initialize the "entry" fact for the graph.

Specified by:
initEntryFact in interface DataflowAnalysis<IsNullValueFrame>

transfer

public void transfer(BasicBlock basicBlock,
                     org.apache.bcel.generic.InstructionHandle end,
                     IsNullValueFrame start,
                     IsNullValueFrame result)
              throws DataflowAnalysisException
Description copied from interface: DataflowAnalysis
Transfer function for the analysis. Taking dataflow facts at start (which might be either the entry or exit of the block, depending on whether the analysis is forwards or backwards), modify result to be the facts at the other end of the block.

Specified by:
transfer in interface DataflowAnalysis<IsNullValueFrame>
Overrides:
transfer in class AbstractDataflowAnalysis<IsNullValueFrame>
Parameters:
basicBlock - the basic block
end - if nonnull, stop before considering this instruction; otherwise, consider all of the instructions in the basic block
start - dataflow facts at beginning of block (if forward analysis) or end of block (if backwards analysis)
result - resulting dataflow facts at other end of block
Throws:
DataflowAnalysisException

startTransfer

public void startTransfer(BasicBlock basicBlock,
                          java.lang.Object start_)
                   throws DataflowAnalysisException
Description copied from class: AbstractDataflowAnalysis
Subclasses may override this. Due to a bug in the 2.2 version of the generics-enabled javac, it is not possible to directly override the transfer() method. This method will be called immediately upon entry to transfer().

Overrides:
startTransfer in class AbstractDataflowAnalysis<IsNullValueFrame>
Parameters:
basicBlock - the basic block
start_ - the start fact for the block
Throws:
DataflowAnalysisException

endTransfer

public void endTransfer(BasicBlock basicBlock,
                        org.apache.bcel.generic.InstructionHandle end,
                        java.lang.Object result_)
                 throws DataflowAnalysisException
Description copied from class: AbstractDataflowAnalysis
Subclasses may override this. Due to a bug in the 2.2 version of the generics-enabled javac, it is not possible to directly override the transfer() method. This method will be called just before exiting transfer().

Overrides:
endTransfer in class AbstractDataflowAnalysis<IsNullValueFrame>
Parameters:
basicBlock - the basic block
end - last instruction analyzed (null if entire block was analyzed)
result_ - the result fact for the block
Throws:
DataflowAnalysisException

transferInstruction

public void transferInstruction(org.apache.bcel.generic.InstructionHandle handle,
                                BasicBlock basicBlock,
                                IsNullValueFrame fact)
                         throws DataflowAnalysisException
Description copied from class: AbstractDataflowAnalysis
Transfer function for a single instruction.

Specified by:
transferInstruction in class AbstractDataflowAnalysis<IsNullValueFrame>
Parameters:
handle - the instruction
basicBlock - the BasicBlock containing the instruction; needed to disambiguate instructions in inlined JSR subroutines
fact - which should be modified based on the instruction
Throws:
DataflowAnalysisException

meetInto

public void meetInto(IsNullValueFrame fact,
                     Edge edge,
                     IsNullValueFrame result)
              throws DataflowAnalysisException
Description copied from interface: DataflowAnalysis
Meet a dataflow fact associated with an incoming edge into another fact. This is used to determine the start fact for a basic block.

Specified by:
meetInto in interface DataflowAnalysis<IsNullValueFrame>
Parameters:
fact - the predecessor fact (incoming edge)
edge - the edge from the predecessor
result - the result fact
Throws:
DataflowAnalysisException

mergeValues

protected void mergeValues(IsNullValueFrame otherFrame,
                           IsNullValueFrame resultFrame,
                           int slot)
                    throws DataflowAnalysisException
Description copied from class: FrameDataflowAnalysis
Merge the values contained in a given slot of two Frames.

Specified by:
mergeValues in class FrameDataflowAnalysis<IsNullValue,IsNullValueFrame>
Parameters:
otherFrame - a Frame
resultFrame - a Frame which will contain the resulting merged value
slot - a slot in both frames
Throws:
DataflowAnalysisException

main

public static void main(java.lang.String[] argv)
                 throws java.lang.Exception
Test driver.

Throws:
java.lang.Exception