edu.umd.cs.findbugs.detect
Class FindOpenStream
java.lang.Object
edu.umd.cs.findbugs.ResourceTrackingDetector<Stream,StreamResourceTracker>
edu.umd.cs.findbugs.detect.FindOpenStream
- All Implemented Interfaces:
- Detector
public class FindOpenStream
- extends ResourceTrackingDetector<Stream,StreamResourceTracker>
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
Method Summary |
void |
analyzeMethod(ClassContext classContext,
org.apache.bcel.classfile.Method method,
StreamResourceTracker resourceTracker,
ResourceCollection<Stream> resourceCollection)
|
StreamResourceTracker |
getResourceTracker(ClassContext classContext,
org.apache.bcel.classfile.Method method)
|
void |
inspectResult(org.apache.bcel.classfile.JavaClass javaClass,
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)
|
Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
DEBUG
static final boolean DEBUG
IGNORE_WRAPPED_UNINTERESTING_STREAMS
static final boolean IGNORE_WRAPPED_UNINTERESTING_STREAMS
streamBaseList
static final org.apache.bcel.generic.ObjectType[] streamBaseList
- List of base classes of tracked resources.
streamFactoryList
static final StreamFactory[] streamFactoryList
- StreamFactory objects used to detect resources
created within analyzed methods.
potentialOpenStreamList
private java.util.List<FindOpenStream.PotentialOpenStream> potentialOpenStreamList
FindOpenStream
public FindOpenStream(BugReporter bugReporter)
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(org.apache.bcel.classfile.JavaClass javaClass,
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