FileDocCategorySizeDatePackage
ExceptionHandlers.javaAPI DocJava SE 5 API4317Fri Aug 26 14:55:26 BST 2005com.sun.org.apache.bcel.internal.verifier.structurals

ExceptionHandlers

public class ExceptionHandlers extends Object
This class allows easy access to ExceptionHandler objects.
version
$Id: ExceptionHandlers.java,v 1.1.1.1 2001/10/29 20:00:38 jvanzyl Exp $
author
Enver Haase

Fields Summary
private Hashtable
exceptionhandlers
The ExceptionHandler instances. Key: InstructionHandle objects, Values: HashSet instances.
Constructors Summary
public ExceptionHandlers(MethodGen mg)
Constructor. Creates a new ExceptionHandlers instance.

		exceptionhandlers = new Hashtable();
		CodeExceptionGen[] cegs = mg.getExceptionHandlers();
		for (int i=0; i<cegs.length; i++){
			ExceptionHandler eh = new ExceptionHandler(cegs[i].getCatchType(), cegs[i].getHandlerPC());
			for (InstructionHandle ih=cegs[i].getStartPC(); ih != cegs[i].getEndPC().getNext(); ih=ih.getNext()){
				HashSet hs;
				hs = (HashSet) exceptionhandlers.get(ih);
				if (hs == null){
					hs = new HashSet();
					exceptionhandlers.put(ih, hs);
				}
				hs.add(eh);
			}
		}
	
Methods Summary
public ExceptionHandler[]getExceptionHandlers(com.sun.org.apache.bcel.internal.generic.InstructionHandle ih)
Returns all the ExceptionHandler instances representing exception handlers that protect the instruction ih.

		HashSet hs = (HashSet) exceptionhandlers.get(ih);
		if (hs == null) return new ExceptionHandler[0];
		else{
			ExceptionHandler[] ret = new ExceptionHandler[hs.size()];
			return (ExceptionHandler[]) (hs.toArray(ret));
		}