edu.umd.cs.findbugs.detect
Class FindNullDeref

java.lang.Object
  extended by edu.umd.cs.findbugs.detect.FindNullDeref
All Implemented Interfaces:
NullDerefAndRedundantComparisonCollector, Detector

public class FindNullDeref
extends java.lang.Object
implements Detector, NullDerefAndRedundantComparisonCollector

A Detector to find instructions where a NullPointerException might be raised. We also look for useless reference comparisons involving null and non-null values.

Author:
David Hovemeyer, William Pugh
See Also:
IsNullValueAnalysis

Field Summary
 
Fields inherited from interface edu.umd.cs.findbugs.Detector
EXP_PRIORITY, HIGH_PRIORITY, IGNORE_PRIORITY, LOW_PRIORITY, NORMAL_PRIORITY
 
Constructor Summary
FindNullDeref(BugReporter bugReporter)
           
 
Method Summary
 void foundNullDeref(Location location, ValueNumber valueNumber, IsNullValue refValue)
          Subclasses should override this method to capture locations where a null pointer is dereferenced.
 void foundRedundantNullCheck(Location location, RedundantBranch redundantBranch)
          Subclasses should override this method to capture locations where a redundant null comparision is performed.
static boolean isThrower(BasicBlock target)
           
 void report()
          This method is called after all classes to be visited.
 void visitClassContext(ClassContext classContext)
          Visit the ClassContext for a class which should be analyzed for instances of bug patterns.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

FindNullDeref

public FindNullDeref(BugReporter bugReporter)
Method Detail

visitClassContext

public void visitClassContext(ClassContext classContext)
Description copied from interface: Detector
Visit the ClassContext for a class which should be analyzed for instances of bug patterns.

Specified by:
visitClassContext in interface Detector
Parameters:
classContext - the ClassContext

report

public void report()
Description copied from interface: Detector
This method is called after all classes to be visited. It should be used by any detectors which accumulate information over all visited classes to generate results.

Specified by:
report in interface Detector

foundNullDeref

public void foundNullDeref(Location location,
                           ValueNumber valueNumber,
                           IsNullValue refValue)
Description copied from interface: NullDerefAndRedundantComparisonCollector
Subclasses should override this method to capture locations where a null pointer is dereferenced.

Specified by:
foundNullDeref in interface NullDerefAndRedundantComparisonCollector
Parameters:
location - the Location of the null dereference
valueNumber - the ValueNumber of the possibly-null value
refValue - the kind of possibly-null value dereferenced

isThrower

public static boolean isThrower(BasicBlock target)

foundRedundantNullCheck

public void foundRedundantNullCheck(Location location,
                                    RedundantBranch redundantBranch)
Description copied from interface: NullDerefAndRedundantComparisonCollector
Subclasses should override this method to capture locations where a redundant null comparision is performed.

Specified by:
foundRedundantNullCheck in interface NullDerefAndRedundantComparisonCollector
Parameters:
location - the Location of the redundant null check
redundantBranch - the RedundantBranch