edu.umd.cs.findbugs.ba
Class BlockType

java.lang.Object
  extended by java.util.BitSet
      extended by edu.umd.cs.findbugs.ba.BlockType
All Implemented Interfaces:
java.io.Serializable, java.lang.Cloneable

public class BlockType
extends java.util.BitSet

Dataflow value representing the current nesting of catch and finally blocks. We assume that any catch block with a non-empty catch type is a user catch block, and any catch block with an empty catch type (i.e., catch all exceptions) is a finally block. This assumption isn't quite accurate, but it seems to be a reasonable first approximation.

If valid (isValid() returns true), a BlockType value is a stack of elements, which are either CATCH or FINALLY values. Call getDepth() to get the current nesting depth. Call get(int n) to get the nth stack item. Call getTopValue() to get the current top of the stack.

If invalid (isValid() returns false), a BlockType value is either top or bottom. These are the special values at the top and bottom of the dataflow lattice.

The dataflow lattice is effectively finite-height because real Java methods are guarnateed to have a finite catch and finally block nesting level.

Author:
David Hovemeyer
See Also:
BlockTypeAnalysis, Serialized Form

Field Summary
static boolean CATCH
           
private  int depth
           
static boolean FINALLY
           
private  boolean isTop
           
private  boolean isValid
           
 
Constructor Summary
BlockType()
          Constructor.
 
Method Summary
 void copyFrom(BlockType other)
          Make this object an exact duplicate of given object.
 int getDepth()
          Get the current nesting depth.
 boolean getTopValue()
          Get the top value on the catch and finally block nesting stack.
 boolean isBottom()
          Return whether or not this is the special "bottom" dataflow value.
 boolean isNormal()
          Return whether or not this value represents "normal" control-flow.
 boolean isTop()
          Return whether or not this is the special "top" dataflow value.
 boolean isValid()
          Return whether or not this value is valid, meaning it contains a valid representation of the nesting of catch and finally blocks.
 void mergeWith(BlockType other)
          Merge other dataflow value into this value.
private  void push(boolean value)
           
 void pushCatch()
          Enter a catch block.
 void pushFinally()
          Enter a finally block.
 boolean sameAs(BlockType other)
          Return whether or not this object is identical to the one given.
 void setBottom()
          Make this the special "bottom" dataflow value.
 void setNormal()
          Make this value represent "normal" control flow.
 void setTop()
          Make this the special "top" dataflow value.
 java.lang.String toString()
           
 
Methods inherited from class java.util.BitSet
and, andNot, cardinality, clear, clear, clear, clone, equals, flip, flip, get, get, hashCode, intersects, isEmpty, length, nextClearBit, nextSetBit, or, set, set, set, set, size, xor
 
Methods inherited from class java.lang.Object
finalize, getClass, notify, notifyAll, wait, wait, wait
 

Field Detail

CATCH

public static final boolean CATCH
See Also:
Constant Field Values

FINALLY

public static final boolean FINALLY
See Also:
Constant Field Values

isValid

private boolean isValid

isTop

private boolean isTop

depth

private int depth
Constructor Detail

BlockType

BlockType()
Constructor. Should only be called by BlockTypeAnalysis.

Method Detail

isValid

public boolean isValid()
Return whether or not this value is valid, meaning it contains a valid representation of the nesting of catch and finally blocks.


getDepth

public int getDepth()
Get the current nesting depth. The value must be valid.


getTopValue

public boolean getTopValue()
Get the top value on the catch and finally block nesting stack.


isNormal

public boolean isNormal()
Return whether or not this value represents "normal" control-flow. Normal control flow are all blocks outside any catch or finally block.


setNormal

public void setNormal()
Make this value represent "normal" control flow.


isTop

public boolean isTop()
Return whether or not this is the special "top" dataflow value.


setTop

public void setTop()
Make this the special "top" dataflow value.


isBottom

public boolean isBottom()
Return whether or not this is the special "bottom" dataflow value.


setBottom

public void setBottom()
Make this the special "bottom" dataflow value.


copyFrom

public void copyFrom(BlockType other)
Make this object an exact duplicate of given object.

Parameters:
other - the other BlockType object

sameAs

public boolean sameAs(BlockType other)
Return whether or not this object is identical to the one given.

Parameters:
other - the other BlockType object
Returns:
true if this object is identical to the one given, false otherwise

mergeWith

public void mergeWith(BlockType other)
Merge other dataflow value into this value.

Parameters:
other - the other BlockType value

pushCatch

public void pushCatch()
Enter a catch block.


pushFinally

public void pushFinally()
Enter a finally block.


toString

public java.lang.String toString()
Overrides:
toString in class java.util.BitSet

push

private void push(boolean value)