Package edu.umd.cs.findbugs.ba.type
Class ExceptionSet
- java.lang.Object
-
- edu.umd.cs.findbugs.ba.type.ExceptionSet
-
- All Implemented Interfaces:
java.io.Serializable
public class ExceptionSet extends java.lang.Object implements java.io.Serializable
Class for keeping track of exceptions that can be thrown by an instruction. We distinguish explicit and implicit exceptions. Explicit exceptions are explicitly declared, thrown, or caught. Implicit exceptions are runtime faults (NPE, array out of bounds) not explicitly handled by the user code.- Author:
- David Hovemeyer
- See Also:
TypeAnalysis
, Serialized Form
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description class
ExceptionSet.ThrownExceptionIterator
Object to iterate over the exception types in the set.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description void
add(org.apache.bcel.generic.ObjectType type, boolean explicit)
Add an exception.void
addAll(ExceptionSet other)
Add all exceptions in the given set.void
addExplicit(org.apache.bcel.generic.ObjectType type)
Add an explicit exception.void
addImplicit(org.apache.bcel.generic.ObjectType type)
Add an implicit exception.void
clear()
Remove all exceptions from the set.boolean
containsCheckedExceptions()
Return whether or not the set contains any checked exceptions.boolean
containsExplicitExceptions()
Return whether or not the set contains any explicit exceptions.ExceptionSet
duplicate()
Return an exact copy of this object.boolean
equals(java.lang.Object o)
org.apache.bcel.generic.Type
getCommonSupertype()
Get the least (lowest in the lattice) common supertype of the exceptions in the set.int
hashCode()
boolean
isEmpty()
Return whether or not the set is empty.boolean
isSingleton(java.lang.String exceptionName)
Checks to see if the exception set is a singleton set containing just the named exceptionExceptionSet.ThrownExceptionIterator
iterator()
Return an iterator over thrown exceptions.void
sawUniversal()
Return whether or not a universal exception handler was reached by the set.boolean
sawUniversalHandler()
Mark the set as having reached a universal exception handler.int
size()
java.lang.String
toString()
-
-
-
Method Detail
-
duplicate
public ExceptionSet duplicate()
Return an exact copy of this object.
-
hashCode
public int hashCode()
- Overrides:
hashCode
in classjava.lang.Object
-
equals
public boolean equals(java.lang.Object o)
- Overrides:
equals
in classjava.lang.Object
-
getCommonSupertype
public org.apache.bcel.generic.Type getCommonSupertype() throws java.lang.ClassNotFoundException
Get the least (lowest in the lattice) common supertype of the exceptions in the set. Returns the special TOP type if the set is empty.- Throws:
java.lang.ClassNotFoundException
-
iterator
public ExceptionSet.ThrownExceptionIterator iterator()
Return an iterator over thrown exceptions.
-
isEmpty
public boolean isEmpty()
Return whether or not the set is empty.
-
isSingleton
public boolean isSingleton(java.lang.String exceptionName)
Checks to see if the exception set is a singleton set containing just the named exception- Parameters:
exceptionName
- (in dotted format)- Returns:
- true if it is
-
addExplicit
public void addExplicit(org.apache.bcel.generic.ObjectType type)
Add an explicit exception.- Parameters:
type
- type of the exception
-
addImplicit
public void addImplicit(org.apache.bcel.generic.ObjectType type)
Add an implicit exception.- Parameters:
type
- type of the exception
-
add
public void add(org.apache.bcel.generic.ObjectType type, boolean explicit)
Add an exception.- Parameters:
type
- the exception typeexplicit
- true if the exception is explicitly declared or thrown, false if implicit
-
addAll
public void addAll(ExceptionSet other)
Add all exceptions in the given set.- Parameters:
other
- the set
-
clear
public void clear()
Remove all exceptions from the set.
-
sawUniversal
public void sawUniversal()
Return whether or not a universal exception handler was reached by the set.
-
sawUniversalHandler
public boolean sawUniversalHandler()
Mark the set as having reached a universal exception handler.
-
containsCheckedExceptions
public boolean containsCheckedExceptions() throws java.lang.ClassNotFoundException
Return whether or not the set contains any checked exceptions.- Throws:
java.lang.ClassNotFoundException
-
containsExplicitExceptions
public boolean containsExplicitExceptions()
Return whether or not the set contains any explicit exceptions.
-
toString
public java.lang.String toString()
- Overrides:
toString
in classjava.lang.Object
-
size
public int size()
-
-