edu.umd.cs.findbugs.detect
Class FindRefComparison

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

public class FindRefComparison
extends java.lang.Object
implements Detector, ExtendedTypes


Nested Class Summary
private static class FindRefComparison.DynamicStringType
          Type representing a dynamically created String.
private static class FindRefComparison.RefComparisonTypeFrameModelingVisitor
           
private static class FindRefComparison.RefComparisonTypeMerger
          Type merger to use the extended String types.
private static class FindRefComparison.StaticStringType
          Type representing a static String.
 
Field Summary
private  BugReporter bugReporter
           
private static boolean DEBUG
           
private static org.apache.bcel.generic.Type dynamicStringTypeInstance
           
private static java.util.BitSet invokeInstanceSet
          Set of opcodes that invoke instance methods on an object.
private static java.util.BitSet prescreenSet
          Set of bytecodes using for prescreening.
private  BugInstance refComparison
           
private static boolean REPORT_ALL_REF_COMPARISONS
           
(package private) static boolean sawStringIntern
           
private static org.apache.bcel.generic.Type staticStringTypeInstance
           
private static java.lang.String STRING_SIGNATURE
           
private  BugInstance stringComparison
           
private static java.util.HashSet<java.lang.String> suspiciousSet
          Classes that are suspicious if compared by reference.
private static byte T_DYNAMIC_STRING
           
private static byte T_STATIC_STRING
           
 
Fields inherited from interface edu.umd.cs.findbugs.Detector
EXP_PRIORITY, HIGH_PRIORITY, LOW_PRIORITY, NORMAL_PRIORITY
 
Fields inherited from interface edu.umd.cs.findbugs.ba.ExtendedTypes
T_AVAIL_TYPE, T_BOTTOM, T_DOUBLE_EXTRA, T_EXCEPTION, T_LONG_EXTRA, T_NULL, T_TOP
 
Constructor Summary
FindRefComparison(BugReporter bugReporter)
           
 
Method Summary
private  void analyzeMethod(ClassContext classContext, org.apache.bcel.classfile.Method method)
           
private  void checkEqualsComparison(Location location, org.apache.bcel.classfile.JavaClass jclass, org.apache.bcel.generic.MethodGen methodGen, TypeDataflow typeDataflow)
           
private  void checkRefComparison(Location location, org.apache.bcel.classfile.JavaClass jclass, org.apache.bcel.generic.MethodGen methodGen, TypeDataflow typeDataflow)
           
static void main(java.lang.String[] argv)
           
 void report()
          This method is called after all classes to be visited.
 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
 

Field Detail

DEBUG

private static final boolean DEBUG

REPORT_ALL_REF_COMPARISONS

private static final boolean REPORT_ALL_REF_COMPARISONS

suspiciousSet

private static final java.util.HashSet<java.lang.String> suspiciousSet
Classes that are suspicious if compared by reference.


invokeInstanceSet

private static final java.util.BitSet invokeInstanceSet
Set of opcodes that invoke instance methods on an object.


prescreenSet

private static final java.util.BitSet prescreenSet
Set of bytecodes using for prescreening.


T_DYNAMIC_STRING

private static final byte T_DYNAMIC_STRING
See Also:
Constant Field Values

T_STATIC_STRING

private static final byte T_STATIC_STRING
See Also:
Constant Field Values

STRING_SIGNATURE

private static final java.lang.String STRING_SIGNATURE
See Also:
Constant Field Values

dynamicStringTypeInstance

private static final org.apache.bcel.generic.Type dynamicStringTypeInstance

staticStringTypeInstance

private static final org.apache.bcel.generic.Type staticStringTypeInstance

bugReporter

private BugReporter bugReporter

stringComparison

private BugInstance stringComparison

refComparison

private BugInstance refComparison

sawStringIntern

static boolean sawStringIntern
Constructor Detail

FindRefComparison

public FindRefComparison(BugReporter bugReporter)
Method Detail

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

checkRefComparison

private void checkRefComparison(Location location,
                                org.apache.bcel.classfile.JavaClass jclass,
                                org.apache.bcel.generic.MethodGen methodGen,
                                TypeDataflow typeDataflow)
                         throws DataflowAnalysisException
Throws:
DataflowAnalysisException

checkEqualsComparison

private void checkEqualsComparison(Location location,
                                   org.apache.bcel.classfile.JavaClass jclass,
                                   org.apache.bcel.generic.MethodGen methodGen,
                                   TypeDataflow typeDataflow)
                            throws DataflowAnalysisException
Throws:
DataflowAnalysisException

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

main

public static void main(java.lang.String[] argv)
                 throws java.lang.Exception
Throws:
java.lang.Exception