Package edu.umd.cs.findbugs.detect
Class Stream
- java.lang.Object
-
- edu.umd.cs.findbugs.ResourceCreationPoint
-
- edu.umd.cs.findbugs.detect.Stream
-
- All Implemented Interfaces:
java.lang.Comparable<Stream>
public class Stream extends ResourceCreationPoint implements java.lang.Comparable<Stream>
A Stream object marks the location in the code where a stream is created. It also is responsible for determining some aspects of how the stream state is tracked by the ResourceValueAnalysis, such as when the stream is opened or closed, and whether implicit exception edges are significant.
TODO: change streamClass and streamBase to ObjectType
TODO: isStreamOpen() and isStreamClose() should probably be abstract, so we can customize how they work for different kinds of streams
-
-
Field Summary
Fields Modifier and Type Field Description private java.lang.String
bugType
private boolean
ignoreImplicitExceptions
private int
instanceParam
private boolean
isClosed
private boolean
isOpenOnCreation
private boolean
isUninteresting
private Location
openLocation
private java.lang.String
streamBase
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description int
compareTo(Stream other)
boolean
equals(java.lang.Object o)
java.lang.String
getBugType()
int
getInstanceParam()
private ResourceValue
getInstanceValue(ResourceValueFrame frame, org.apache.bcel.generic.InvokeInstruction inv, org.apache.bcel.generic.ConstantPoolGen cpg)
Location
getOpenLocation()
java.lang.String
getStreamBase()
int
hashCode()
boolean
ignoreImplicitExceptions()
boolean
isClosed()
Return whether or not the Stream is closed on all paths out of the method.boolean
isOpenOnCreation()
boolean
isStreamClose(BasicBlock basicBlock, org.apache.bcel.generic.InstructionHandle handle, org.apache.bcel.generic.ConstantPoolGen cpg, ResourceValueFrame frame, RepositoryLookupFailureCallback lookupFailureCallback)
boolean
isStreamOpen(BasicBlock basicBlock, org.apache.bcel.generic.InstructionHandle handle, org.apache.bcel.generic.ConstantPoolGen cpg, ResourceValueFrame frame)
boolean
isUninteresting()
private boolean
matchMethod(org.apache.bcel.generic.InvokeInstruction inv, org.apache.bcel.generic.ConstantPoolGen cpg, java.lang.String className, java.lang.String methodName)
static boolean
mightCloseStream(BasicBlock basicBlock, org.apache.bcel.generic.InstructionHandle handle, org.apache.bcel.generic.ConstantPoolGen cpg)
private boolean
relatedType(java.lang.String classClosed)
void
setClosed()
Set this Stream has having been closed on all paths out of the method.Stream
setIgnoreImplicitExceptions(boolean enable)
Mark whether or not implicit exception edges should be ignored by ResourceValueAnalysis when determining whether or not stream is closed on all paths out of method.void
setInstanceParam(int instanceParam)
Set the number of the parameter which passes the stream instance.Stream
setInteresting(java.lang.String bugType)
Mark this Stream as interesting.Stream
setIsOpenOnCreation(boolean enable)
Mark whether or not Stream is open as soon as it is created, or whether a later method or constructor must explicitly open it.void
setOpenLocation(Location openLocation)
java.lang.String
toString()
-
Methods inherited from class edu.umd.cs.findbugs.ResourceCreationPoint
getLocation, getResourceClass
-
-
-
-
Field Detail
-
streamBase
private final java.lang.String streamBase
-
isUninteresting
private boolean isUninteresting
-
isOpenOnCreation
private boolean isOpenOnCreation
-
openLocation
private Location openLocation
-
ignoreImplicitExceptions
private boolean ignoreImplicitExceptions
-
bugType
private java.lang.String bugType
-
instanceParam
private int instanceParam
-
isClosed
private boolean isClosed
-
-
Constructor Detail
-
Stream
public Stream(Location location, java.lang.String streamClass, java.lang.String streamBase)
Constructor. By default, Stream objects are marked as uninteresting. setInteresting("BUG_TYPE") must be called explicitly to mark the Stream as interesting.- Parameters:
location
- where the stream is createdstreamClass
- type of StreamstreamBase
- highest class in the class hierarchy through which stream's close() method could be called
-
-
Method Detail
-
toString
public java.lang.String toString()
- Overrides:
toString
in classjava.lang.Object
-
setInteresting
public Stream setInteresting(java.lang.String bugType)
Mark this Stream as interesting.- Parameters:
bugType
- the bug type that should be reported if the stream is not closed on all paths out of the method
-
setIgnoreImplicitExceptions
public Stream setIgnoreImplicitExceptions(boolean enable)
Mark whether or not implicit exception edges should be ignored by ResourceValueAnalysis when determining whether or not stream is closed on all paths out of method.
-
setIsOpenOnCreation
public Stream setIsOpenOnCreation(boolean enable)
Mark whether or not Stream is open as soon as it is created, or whether a later method or constructor must explicitly open it.
-
setInstanceParam
public void setInstanceParam(int instanceParam)
Set the number of the parameter which passes the stream instance.- Parameters:
instanceParam
- number of the parameter passing the stream instance
-
setClosed
public void setClosed()
Set this Stream has having been closed on all paths out of the method.
-
getStreamBase
public java.lang.String getStreamBase()
-
isUninteresting
public boolean isUninteresting()
-
isOpenOnCreation
public boolean isOpenOnCreation()
-
setOpenLocation
public void setOpenLocation(Location openLocation)
-
getOpenLocation
public Location getOpenLocation()
-
ignoreImplicitExceptions
public boolean ignoreImplicitExceptions()
-
getInstanceParam
public int getInstanceParam()
-
getBugType
public java.lang.String getBugType()
-
isClosed
public boolean isClosed()
Return whether or not the Stream is closed on all paths out of the method.
-
isStreamOpen
public boolean isStreamOpen(BasicBlock basicBlock, org.apache.bcel.generic.InstructionHandle handle, org.apache.bcel.generic.ConstantPoolGen cpg, ResourceValueFrame frame)
-
mightCloseStream
public static boolean mightCloseStream(BasicBlock basicBlock, org.apache.bcel.generic.InstructionHandle handle, org.apache.bcel.generic.ConstantPoolGen cpg)
-
isStreamClose
public boolean isStreamClose(BasicBlock basicBlock, org.apache.bcel.generic.InstructionHandle handle, org.apache.bcel.generic.ConstantPoolGen cpg, ResourceValueFrame frame, RepositoryLookupFailureCallback lookupFailureCallback)
-
relatedType
private boolean relatedType(java.lang.String classClosed) throws java.lang.ClassNotFoundException
- Throws:
java.lang.ClassNotFoundException
-
getInstanceValue
private ResourceValue getInstanceValue(ResourceValueFrame frame, org.apache.bcel.generic.InvokeInstruction inv, org.apache.bcel.generic.ConstantPoolGen cpg)
-
matchMethod
private boolean matchMethod(org.apache.bcel.generic.InvokeInstruction inv, org.apache.bcel.generic.ConstantPoolGen cpg, java.lang.String className, java.lang.String methodName)
-
hashCode
public int hashCode()
- Overrides:
hashCode
in classjava.lang.Object
-
equals
public boolean equals(java.lang.Object o)
- Overrides:
equals
in classjava.lang.Object
-
-