FindBugs™ 1.3.9

edu.umd.cs.findbugs.ba.deref
Class UnconditionalValueDerefAnalysis

java.lang.Object
  extended by edu.umd.cs.findbugs.ba.BasicAbstractDataflowAnalysis<Fact>
      extended by edu.umd.cs.findbugs.ba.AbstractDataflowAnalysis<Fact>
          extended by edu.umd.cs.findbugs.ba.BackwardDataflowAnalysis<UnconditionalValueDerefSet>
              extended by edu.umd.cs.findbugs.ba.deref.UnconditionalValueDerefAnalysis
All Implemented Interfaces:
DataflowAnalysis<UnconditionalValueDerefSet>

public class UnconditionalValueDerefAnalysis
extends BackwardDataflowAnalysis<UnconditionalValueDerefSet>

Dataflow analysis to find values unconditionally dereferenced in the future.

Author:
David Hovemeyer

Field Summary
static boolean ASSUME_NONZERO_TRIP_LOOPS
           
static boolean CHECK_ANNOTATIONS
           
static boolean CHECK_CALLS
           
static boolean DEBUG
           
static boolean DEBUG_CHECK_CALLS
           
static boolean IGNORE_DEREF_OF_NCP
           
static boolean VERBOSE_NULLARG_DEBUG
           
 
Constructor Summary
UnconditionalValueDerefAnalysis(ReverseDepthFirstSearch rdfs, DepthFirstSearch dfs, CFG cfg, org.apache.bcel.classfile.Method method, org.apache.bcel.generic.MethodGen methodGen, ValueNumberDataflow vnaDataflow, AssertionMethods assertionMethods)
          Constructor.
 
Method Summary
static java.util.Set<ValueNumber> checkAllNonNullParams(Location location, ValueNumberFrame vnaFrame, org.apache.bcel.generic.ConstantPoolGen constantPool, org.apache.bcel.classfile.Method method, IsNullValueDataflow invDataflow, TypeDataflow typeDataflow)
           
static java.util.Set<ValueNumber> checkNonNullParams(Location location, ValueNumberFrame vnaFrame, org.apache.bcel.generic.ConstantPoolGen constantPool, org.apache.bcel.classfile.Method method, IsNullValueFrame invFrame)
           
static java.util.Set<ValueNumber> checkUnconditionalDerefDatabase(Location location, ValueNumberFrame vnaFrame, org.apache.bcel.generic.ConstantPoolGen constantPool, IsNullValueFrame invFrame, TypeDataflow typeDataflow)
           
 void clearDerefsOnNonNullBranches(IsNullValueDataflow invDataflow)
          HACK: use the given is-null dataflow to clear deref sets for values that are known to be definitely non-null on a branch.
 void copy(UnconditionalValueDerefSet source, UnconditionalValueDerefSet dest)
          Copy dataflow facts.
 UnconditionalValueDerefSet createFact()
          Create empty (uninitialized) dataflow facts for one program point.
 int getLastUpdateTimestamp(UnconditionalValueDerefSet fact)
           
 void initEntryFact(UnconditionalValueDerefSet result)
          Initialize the "entry" fact for the graph.
 boolean isFactValid(UnconditionalValueDerefSet fact)
          Determine whether the given fact is valid (neither top nor bottom).
static boolean isNullCheck(org.apache.bcel.generic.InstructionHandle h, org.apache.bcel.generic.ConstantPoolGen cpg)
           
 boolean isTop(UnconditionalValueDerefSet fact)
          Is the given fact the top value.
 void makeFactTop(UnconditionalValueDerefSet fact)
          Make given fact the top value.
 void meetInto(UnconditionalValueDerefSet fact, Edge edge, UnconditionalValueDerefSet result)
          Meet a dataflow fact associated with an incoming edge into another fact.
 void meetInto(UnconditionalValueDerefSet fact, Edge edge, UnconditionalValueDerefSet result, boolean onlyEdge)
           
static boolean reportPotentialDereference(Location location, IsNullValueFrame invFrame)
           
 boolean same(UnconditionalValueDerefSet fact1, UnconditionalValueDerefSet fact2)
          Are given dataflow facts the same?
 void setLastUpdateTimestamp(UnconditionalValueDerefSet fact, int lastUpdate)
           
 void setTypeDataflow(TypeDataflow typeDataflow)
           
 void startIteration()
          Called before beginning an iteration of analysis.
 void transferInstruction(org.apache.bcel.generic.InstructionHandle handle, BasicBlock basicBlock, UnconditionalValueDerefSet fact)
          Transfer function for a single instruction.
 
Methods inherited from class edu.umd.cs.findbugs.ba.BackwardDataflowAnalysis
getBlockOrder, getReverseDepthFirstSearch, isForwards
 
Methods inherited from class edu.umd.cs.findbugs.ba.AbstractDataflowAnalysis
getFactAfterLocation, getFactAtLocation, transfer
 
Methods inherited from class edu.umd.cs.findbugs.ba.BasicAbstractDataflowAnalysis
edgeTransfer, factToString, finishIteration, getFactOnEdge, getResultFact, getStartFact, resultFactIterator
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

DEBUG

public static final boolean DEBUG

ASSUME_NONZERO_TRIP_LOOPS

public static final boolean ASSUME_NONZERO_TRIP_LOOPS

IGNORE_DEREF_OF_NCP

public static final boolean IGNORE_DEREF_OF_NCP

CHECK_ANNOTATIONS

public static final boolean CHECK_ANNOTATIONS

CHECK_CALLS

public static final boolean CHECK_CALLS

DEBUG_CHECK_CALLS

public static final boolean DEBUG_CHECK_CALLS

VERBOSE_NULLARG_DEBUG

public static final boolean VERBOSE_NULLARG_DEBUG
Constructor Detail

UnconditionalValueDerefAnalysis

public UnconditionalValueDerefAnalysis(ReverseDepthFirstSearch rdfs,
                                       DepthFirstSearch dfs,
                                       CFG cfg,
                                       org.apache.bcel.classfile.Method method,
                                       org.apache.bcel.generic.MethodGen methodGen,
                                       ValueNumberDataflow vnaDataflow,
                                       AssertionMethods assertionMethods)
Constructor.

Parameters:
rdfs - the reverse depth-first-search (for the block order)
dfs - TODO
cfg - the CFG for the method
method - TODO
methodGen - the MethodGen for the method
vnaDataflow -
assertionMethods - AssertionMethods for the analyzed class
Method Detail

clearDerefsOnNonNullBranches

public void clearDerefsOnNonNullBranches(IsNullValueDataflow invDataflow)
HACK: use the given is-null dataflow to clear deref sets for values that are known to be definitely non-null on a branch.

Parameters:
invDataflow - the IsNullValueDataflow to use

setTypeDataflow

public void setTypeDataflow(TypeDataflow typeDataflow)

isFactValid

public boolean isFactValid(UnconditionalValueDerefSet fact)
Description copied from class: AbstractDataflowAnalysis
Determine whether the given fact is valid (neither top nor bottom).

Specified by:
isFactValid in class AbstractDataflowAnalysis<UnconditionalValueDerefSet>

isNullCheck

public static boolean isNullCheck(org.apache.bcel.generic.InstructionHandle h,
                                  org.apache.bcel.generic.ConstantPoolGen cpg)

reportPotentialDereference

public static boolean reportPotentialDereference(Location location,
                                                 IsNullValueFrame invFrame)
                                          throws DataflowAnalysisException
Throws:
DataflowAnalysisException

transferInstruction

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

Specified by:
transferInstruction in class AbstractDataflowAnalysis<UnconditionalValueDerefSet>
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

checkUnconditionalDerefDatabase

public static java.util.Set<ValueNumber> checkUnconditionalDerefDatabase(Location location,
                                                                         ValueNumberFrame vnaFrame,
                                                                         org.apache.bcel.generic.ConstantPoolGen constantPool,
                                                                         @CheckForNull
                                                                         IsNullValueFrame invFrame,
                                                                         TypeDataflow typeDataflow)
                                                                  throws DataflowAnalysisException
Throws:
DataflowAnalysisException

checkAllNonNullParams

public static java.util.Set<ValueNumber> checkAllNonNullParams(Location location,
                                                               ValueNumberFrame vnaFrame,
                                                               org.apache.bcel.generic.ConstantPoolGen constantPool,
                                                               @CheckForNull
                                                               org.apache.bcel.classfile.Method method,
                                                               @CheckForNull
                                                               IsNullValueDataflow invDataflow,
                                                               TypeDataflow typeDataflow)
                                                        throws DataflowAnalysisException
Throws:
DataflowAnalysisException

checkNonNullParams

public static java.util.Set<ValueNumber> checkNonNullParams(Location location,
                                                            ValueNumberFrame vnaFrame,
                                                            org.apache.bcel.generic.ConstantPoolGen constantPool,
                                                            @CheckForNull
                                                            org.apache.bcel.classfile.Method method,
                                                            @CheckForNull
                                                            IsNullValueFrame invFrame)
                                                     throws DataflowAnalysisException
Throws:
DataflowAnalysisException

copy

public void copy(UnconditionalValueDerefSet source,
                 UnconditionalValueDerefSet dest)
Description copied from interface: DataflowAnalysis
Copy dataflow facts.


createFact

public UnconditionalValueDerefSet 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.


initEntryFact

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

Throws:
DataflowAnalysisException

makeFactTop

public void makeFactTop(UnconditionalValueDerefSet fact)
Description copied from interface: DataflowAnalysis
Make given fact the top value.


isTop

public boolean isTop(UnconditionalValueDerefSet fact)
Description copied from interface: DataflowAnalysis
Is the given fact the top value.


meetInto

public void meetInto(UnconditionalValueDerefSet fact,
                     Edge edge,
                     UnconditionalValueDerefSet 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.

Parameters:
fact - the predecessor fact (incoming edge)
edge - the edge from the predecessor
result - the result fact
Throws:
DataflowAnalysisException

meetInto

public void meetInto(UnconditionalValueDerefSet fact,
                     Edge edge,
                     UnconditionalValueDerefSet result,
                     boolean onlyEdge)
              throws DataflowAnalysisException
Throws:
DataflowAnalysisException

same

public boolean same(UnconditionalValueDerefSet fact1,
                    UnconditionalValueDerefSet fact2)
Description copied from interface: DataflowAnalysis
Are given dataflow facts the same?


startIteration

public void startIteration()
Description copied from interface: DataflowAnalysis
Called before beginning an iteration of analysis. Each iteration visits every basic block in the CFG.

Specified by:
startIteration in interface DataflowAnalysis<UnconditionalValueDerefSet>
Overrides:
startIteration in class BasicAbstractDataflowAnalysis<UnconditionalValueDerefSet>

getLastUpdateTimestamp

public int getLastUpdateTimestamp(UnconditionalValueDerefSet fact)
Specified by:
getLastUpdateTimestamp in interface DataflowAnalysis<UnconditionalValueDerefSet>
Overrides:
getLastUpdateTimestamp in class BasicAbstractDataflowAnalysis<UnconditionalValueDerefSet>

setLastUpdateTimestamp

public void setLastUpdateTimestamp(UnconditionalValueDerefSet fact,
                                   int lastUpdate)
Specified by:
setLastUpdateTimestamp in interface DataflowAnalysis<UnconditionalValueDerefSet>
Overrides:
setLastUpdateTimestamp in class BasicAbstractDataflowAnalysis<UnconditionalValueDerefSet>

FindBugs™ 1.3.9

FindBugs™ is licenced under the LGPL. Copyright © 2006 University of Maryland.