1 30 31 47 48 49 52 53 package jbet; 54 import java.util.*; 55 import java.io.*; 56 57 public class ExceptionRec implements Cloneable { 58 59 public BranchTarget start = new BranchTarget(); public BranchTarget end = new BranchTarget(); public BranchTarget handler = new BranchTarget(); public String catchType; int catchIndex; 65 int marker; 66 67 ExceptionRec dup() { 68 try { 69 return (ExceptionRec) clone(); 70 } catch (CloneNotSupportedException e) { 71 return null; 72 } 73 } 74 75 public ExceptionRec (Instruction start, Instruction end, Instruction handler, String ct) { 76 this.start.instr = start; 77 this.end.instr = end; 78 this.handler.instr = handler; 79 catchType = ct; 80 } 81 82 ExceptionRec (DataInputStream dataIn, ConstantPool constantPool) 83 throws IOException, ClassFileException { 84 85 start.offset = dataIn.readUnsignedShort(); 86 end.offset = dataIn.readUnsignedShort(); 87 handler.offset = dataIn.readUnsignedShort(); 88 89 catchIndex = dataIn.readUnsignedShort(); 90 catchType = catchIndex == 0 ? null : constantPool.cpClassAt(catchIndex).string(); 91 } 92 93 94 void resolveConstants(ConstantPool constantPool) { 95 if (catchType != null) 96 catchIndex = constantPool.internClass(catchType); 97 else 98 catchIndex = 0; 99 } 100 101 void writeFile (DataOutputStream dataOut) throws IOException { 102 dataOut.writeShort (start.offset); 103 dataOut.writeShort (end.offset); 104 dataOut.writeShort (handler.offset); 105 dataOut.writeShort (catchIndex ); 106 } 107 108 109 void print (LineWriter out) { 110 out.println ("\tException: PCrange(" + start.instr.pc() + "-" + 111 (end.instr==null?"":""+end.instr.pc()) + ") handlerPC(" + 112 handler.instr.pc() + ") catchType(" + catchType + ")" ); 113 } 114 115 ExceptionRec () {}; 116 117 118 119 } 120 | Popular Tags |