1 package com.sun.org.apache.bcel.internal.verifier.structurals; 2 3 56 57 import com.sun.org.apache.bcel.internal.generic.*; 58 import java.util.HashSet ; 59 import java.util.Hashtable ; 60 61 67 public class ExceptionHandlers{ 68 72 private Hashtable exceptionhandlers; 73 74 77 public ExceptionHandlers(MethodGen mg){ 78 exceptionhandlers = new Hashtable (); 79 CodeExceptionGen[] cegs = mg.getExceptionHandlers(); 80 for (int i=0; i<cegs.length; i++){ 81 ExceptionHandler eh = new ExceptionHandler(cegs[i].getCatchType(), cegs[i].getHandlerPC()); 82 for (InstructionHandle ih=cegs[i].getStartPC(); ih != cegs[i].getEndPC().getNext(); ih=ih.getNext()){ 83 HashSet hs; 84 hs = (HashSet ) exceptionhandlers.get(ih); 85 if (hs == null){ 86 hs = new HashSet (); 87 exceptionhandlers.put(ih, hs); 88 } 89 hs.add(eh); 90 } 91 } 92 } 93 94 98 public ExceptionHandler[] getExceptionHandlers(InstructionHandle ih){ 99 HashSet hs = (HashSet ) exceptionhandlers.get(ih); 100 if (hs == null) return new ExceptionHandler[0]; 101 else{ 102 ExceptionHandler[] ret = new ExceptionHandler[hs.size()]; 103 return (ExceptionHandler[]) (hs.toArray(ret)); 104 } 105 } 106 107 } 108 | Popular Tags |