edu.umd.cs.findbugs.detect
Class FindNullDeref
java.lang.Object
edu.umd.cs.findbugs.detect.FindNullDeref
- All Implemented Interfaces:
- Detector
public class FindNullDeref
- extends java.lang.Object
- implements Detector
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
- See Also:
IsNullValueAnalysis
Method Summary |
private void |
analyzeIfNullBranch(org.apache.bcel.classfile.Method method,
IsNullValueDataflow invDataflow,
BasicBlock basicBlock,
org.apache.bcel.generic.InstructionHandle lastHandle)
|
private void |
analyzeMethod(ClassContext classContext,
org.apache.bcel.classfile.Method method)
|
private void |
analyzeNullCheck(ClassContext classContext,
org.apache.bcel.classfile.Method method,
IsNullValueDataflow invDataflow,
BasicBlock basicBlock)
|
private void |
analyzeRefComparisonBranch(org.apache.bcel.classfile.Method method,
IsNullValueDataflow invDataflow,
BasicBlock basicBlock,
org.apache.bcel.generic.InstructionHandle lastHandle)
|
private static int |
getLineNumber(org.apache.bcel.classfile.Method method,
org.apache.bcel.generic.InstructionHandle handle)
|
void |
report()
This method is called after all classes to be visited. |
private void |
reportNullDeref(ClassContext classContext,
org.apache.bcel.classfile.Method method,
org.apache.bcel.generic.InstructionHandle exceptionThrowerHandle,
java.lang.String type,
int priority)
|
private void |
reportRedundantNullCheck(ClassContext classContext,
org.apache.bcel.classfile.Method method,
org.apache.bcel.generic.InstructionHandle handle,
FindNullDeref.RedundantBranch redundantBranch)
|
void |
setAnalysisContext(AnalysisContext analysisContext)
Set the AnalysisContext that will be used. |
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 |
DEBUG
private static final boolean DEBUG
bugReporter
private BugReporter bugReporter
redundantBranchList
private java.util.List<FindNullDeref.RedundantBranch> redundantBranchList
definitelySameBranchSet
private java.util.BitSet definitelySameBranchSet
definitelyDifferentBranchSet
private java.util.BitSet definitelyDifferentBranchSet
undeterminedBranchSet
private java.util.BitSet undeterminedBranchSet
FindNullDeref
public FindNullDeref(BugReporter bugReporter)
setAnalysisContext
public void setAnalysisContext(AnalysisContext analysisContext)
- Description copied from interface:
Detector
- Set the AnalysisContext that will be used.
This is called before visitClassContext() is called
on any class to be analyzed.
- Specified by:
setAnalysisContext
in interface Detector
- Parameters:
analysisContext
- the AnalysisContext
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
analyzeMethod
private void analyzeMethod(ClassContext classContext,
org.apache.bcel.classfile.Method method)
throws CFGBuilderException,
DataflowAnalysisException
- Throws:
CFGBuilderException
DataflowAnalysisException
analyzeNullCheck
private void analyzeNullCheck(ClassContext classContext,
org.apache.bcel.classfile.Method method,
IsNullValueDataflow invDataflow,
BasicBlock basicBlock)
throws DataflowAnalysisException
- Throws:
DataflowAnalysisException
analyzeRefComparisonBranch
private void analyzeRefComparisonBranch(org.apache.bcel.classfile.Method method,
IsNullValueDataflow invDataflow,
BasicBlock basicBlock,
org.apache.bcel.generic.InstructionHandle lastHandle)
throws DataflowAnalysisException
- Throws:
DataflowAnalysisException
analyzeIfNullBranch
private void analyzeIfNullBranch(org.apache.bcel.classfile.Method method,
IsNullValueDataflow invDataflow,
BasicBlock basicBlock,
org.apache.bcel.generic.InstructionHandle lastHandle)
throws DataflowAnalysisException
- Throws:
DataflowAnalysisException
getLineNumber
private static int getLineNumber(org.apache.bcel.classfile.Method method,
org.apache.bcel.generic.InstructionHandle handle)
reportNullDeref
private void reportNullDeref(ClassContext classContext,
org.apache.bcel.classfile.Method method,
org.apache.bcel.generic.InstructionHandle exceptionThrowerHandle,
java.lang.String type,
int priority)
reportRedundantNullCheck
private void reportRedundantNullCheck(ClassContext classContext,
org.apache.bcel.classfile.Method method,
org.apache.bcel.generic.InstructionHandle handle,
FindNullDeref.RedundantBranch redundantBranch)
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