edu.umd.cs.findbugs.detect

Class StreamResourceTracker

public class StreamResourceTracker extends Object implements ResourceTracker<Stream>

Resource tracker which determines where streams are created, and how they are used within the method.

Author: David Hovemeyer

Constructor Summary
StreamResourceTracker(StreamFactory[] streamFactoryList, RepositoryLookupFailureCallback lookupFailureCallback)
Constructor.
Method Summary
voidaddStreamEscape(Stream source, Location target)
Indicate that a stream escapes at the given target Location.
voidaddStreamOpenLocation(Location streamOpenLocation, Stream stream)
Indicate that a stream is constructed at this Location.
ResourceValueFrameModelingVisitorcreateVisitor(Stream resource, ConstantPoolGen cpg)
StreamEquivalenceClassgetStreamEquivalenceClass(Stream stream)
Get the equivalence class for given stream.
booleanignoreExceptionEdge(Edge edge, Stream resource, ConstantPoolGen cpg)
booleanignoreImplicitExceptions(Stream resource)
booleanisParamInstance(Stream resource, int slot)
booleanisResourceClose(BasicBlock basicBlock, InstructionHandle handle, ConstantPoolGen cpg, Stream resource, ResourceValueFrame frame)
StreamisResourceCreation(BasicBlock basicBlock, InstructionHandle handle, ConstantPoolGen cpg)
booleanisResourceOpen(BasicBlock basicBlock, InstructionHandle handle, ConstantPoolGen cpg, Stream resource, ResourceValueFrame frame)
booleanisUninterestingStreamEscape(Stream stream)
Determine if an uninteresting stream escapes at given location. markTransitiveUninterestingStreamEscapes() should be called first.
voidmarkTransitiveUninterestingStreamEscapes()
Transitively mark all streams into which uninteresting streams (such as System.out) escape.
voidsetResourceCollection(ResourceCollection<Stream> resourceCollection)
Set the precomputed ResourceCollection for the method.

Constructor Detail

StreamResourceTracker

public StreamResourceTracker(StreamFactory[] streamFactoryList, RepositoryLookupFailureCallback lookupFailureCallback)
Constructor.

Parameters: streamFactoryList array of StreamFactory objects which determine where streams are created lookupFailureCallback used when class hierarchy lookups fail

Method Detail

addStreamEscape

public void addStreamEscape(Stream source, Location target)
Indicate that a stream escapes at the given target Location.

Parameters: source the Stream that is escaping target the target Location (where the stream escapes)

addStreamOpenLocation

public void addStreamOpenLocation(Location streamOpenLocation, Stream stream)
Indicate that a stream is constructed at this Location.

Parameters: streamOpenLocation the Location stream the Stream opened at this Location

createVisitor

public ResourceValueFrameModelingVisitor createVisitor(Stream resource, ConstantPoolGen cpg)

getStreamEquivalenceClass

public StreamEquivalenceClass getStreamEquivalenceClass(Stream stream)
Get the equivalence class for given stream. May only be called if markTransitiveUninterestingStreamEscapes() has been called.

Parameters: stream the stream

Returns: the set containing the equivalence class for the given stream

ignoreExceptionEdge

public boolean ignoreExceptionEdge(Edge edge, Stream resource, ConstantPoolGen cpg)

ignoreImplicitExceptions

public boolean ignoreImplicitExceptions(Stream resource)

isParamInstance

public boolean isParamInstance(Stream resource, int slot)

isResourceClose

public boolean isResourceClose(BasicBlock basicBlock, InstructionHandle handle, ConstantPoolGen cpg, Stream resource, ResourceValueFrame frame)

isResourceCreation

public Stream isResourceCreation(BasicBlock basicBlock, InstructionHandle handle, ConstantPoolGen cpg)

isResourceOpen

public boolean isResourceOpen(BasicBlock basicBlock, InstructionHandle handle, ConstantPoolGen cpg, Stream resource, ResourceValueFrame frame)

isUninterestingStreamEscape

public boolean isUninterestingStreamEscape(Stream stream)
Determine if an uninteresting stream escapes at given location. markTransitiveUninterestingStreamEscapes() should be called first.

Parameters: stream the stream

Returns: true if an uninteresting stream escapes at the location

markTransitiveUninterestingStreamEscapes

public void markTransitiveUninterestingStreamEscapes()
Transitively mark all streams into which uninteresting streams (such as System.out) escape. This handles the rule that wrapping an uninteresting stream makes the wrapper uninteresting as well.

setResourceCollection

public void setResourceCollection(ResourceCollection<Stream> resourceCollection)
Set the precomputed ResourceCollection for the method.
FindBugs™ is licenced under the LGPL. Copyright © 2006 University of Maryland.