edu.umd.cs.findbugs.detect
Class FindOpenStream

java.lang.Object
  extended by edu.umd.cs.findbugs.ResourceTrackingDetector<Stream,StreamResourceTracker>
      extended by edu.umd.cs.findbugs.detect.FindOpenStream
All Implemented Interfaces:
Detector, StatelessDetector, java.lang.Cloneable

public class FindOpenStream
extends ResourceTrackingDetector<Stream,StreamResourceTracker>
implements StatelessDetector

A Detector to look for streams that are opened in a method, do not escape the method, and are not closed on all paths out of the method. Note that "stream" is a bit misleading, since we also use the detector to look for database resources that aren't closed.

Author:
David Hovemeyer

Field Summary
 
Fields inherited from class edu.umd.cs.findbugs.ResourceTrackingDetector
bugReporter
 
Fields inherited from interface edu.umd.cs.findbugs.Detector
EXP_PRIORITY, HIGH_PRIORITY, IGNORE_PRIORITY, LOW_PRIORITY, NORMAL_PRIORITY
 
Constructor Summary
FindOpenStream(BugReporter bugReporter)
           
 
Method Summary
 void analyzeMethod(ClassContext classContext, org.apache.bcel.classfile.Method method, StreamResourceTracker resourceTracker, ResourceCollection<Stream> resourceCollection)
           
 java.lang.Object clone()
           
 StreamResourceTracker getResourceTracker(ClassContext classContext, org.apache.bcel.classfile.Method method)
           
 void inspectResult(ClassContext classContext, org.apache.bcel.generic.MethodGen methodGen, CFG cfg, Dataflow<ResourceValueFrame,ResourceValueAnalysis<Stream>> dataflow, Stream stream)
           
static boolean isMainMethod(org.apache.bcel.classfile.Method method)
           
static void main(java.lang.String[] argv)
           
 boolean prescreen(ClassContext classContext, org.apache.bcel.classfile.Method method)
           
 void visitClassContext(ClassContext classContext)
          Visit the ClassContext for a class which should be analyzed for instances of bug patterns.
 
Methods inherited from class edu.umd.cs.findbugs.ResourceTrackingDetector
report
 
Methods inherited from class java.lang.Object
equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

FindOpenStream

public FindOpenStream(BugReporter bugReporter)
Method Detail

clone

public java.lang.Object clone()
                       throws java.lang.CloneNotSupportedException
Specified by:
clone in interface StatelessDetector
Overrides:
clone in class java.lang.Object
Throws:
java.lang.CloneNotSupportedException

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
Overrides:
visitClassContext in class ResourceTrackingDetector<Stream,StreamResourceTracker>
Parameters:
classContext - the ClassContext

prescreen

public boolean prescreen(ClassContext classContext,
                         org.apache.bcel.classfile.Method method)
Specified by:
prescreen in class ResourceTrackingDetector<Stream,StreamResourceTracker>

getResourceTracker

public StreamResourceTracker getResourceTracker(ClassContext classContext,
                                                org.apache.bcel.classfile.Method method)
Specified by:
getResourceTracker in class ResourceTrackingDetector<Stream,StreamResourceTracker>

isMainMethod

public static boolean isMainMethod(org.apache.bcel.classfile.Method method)

analyzeMethod

public void analyzeMethod(ClassContext classContext,
                          org.apache.bcel.classfile.Method method,
                          StreamResourceTracker resourceTracker,
                          ResourceCollection<Stream> resourceCollection)
                   throws CFGBuilderException,
                          DataflowAnalysisException
Overrides:
analyzeMethod in class ResourceTrackingDetector<Stream,StreamResourceTracker>
Throws:
CFGBuilderException
DataflowAnalysisException

inspectResult

public void inspectResult(ClassContext classContext,
                          org.apache.bcel.generic.MethodGen methodGen,
                          CFG cfg,
                          Dataflow<ResourceValueFrame,ResourceValueAnalysis<Stream>> dataflow,
                          Stream stream)
Specified by:
inspectResult in class ResourceTrackingDetector<Stream,StreamResourceTracker>

main

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