1 23 24 25 package com.sun.jdo.api.persistence.enhancer.classfile; 26 27 import java.io.*; 28 29 33 34 public class ExceptionRange { 35 36 private InsnTarget excStartPC; 37 38 39 private InsnTarget excEndPC; 40 41 42 private InsnTarget excHandlerPC; 43 44 45 private ConstClass excCatchType; 46 47 48 49 52 public InsnTarget startPC() { 53 return excStartPC; 54 } 55 56 59 public InsnTarget endPC() { 60 return excEndPC; 61 } 62 63 66 public InsnTarget handlerPC() { 67 return excHandlerPC; 68 } 69 70 74 public ConstClass catchType() { 75 return excCatchType; 76 } 77 78 81 82 public ExceptionRange(InsnTarget startPC, InsnTarget endPC, 83 InsnTarget handlerPC, ConstClass catchType) { 84 excStartPC = startPC; 85 excEndPC = endPC; 86 excHandlerPC = handlerPC; 87 excCatchType = catchType; 88 } 89 90 91 92 static ExceptionRange read(DataInputStream data, CodeEnv env) 93 throws IOException { 94 InsnTarget startPC = env.getTarget(data.readUnsignedShort()); 95 InsnTarget endPC = env.getTarget(data.readUnsignedShort()); 96 InsnTarget handlerPC = env.getTarget(data.readUnsignedShort()); 97 ConstClass catchType = 98 (ConstClass) env.pool().constantAt(data.readUnsignedShort()); 99 return new ExceptionRange(startPC, endPC, handlerPC, catchType); 100 } 101 102 void write(DataOutputStream out) throws IOException { 103 out.writeShort(excStartPC.offset()); 104 out.writeShort(excEndPC.offset()); 105 out.writeShort(excHandlerPC.offset()); 106 out.writeShort(excCatchType == null ? 0 : excCatchType.getIndex()); 107 } 108 109 void print(PrintStream out, int indent) { 110 ClassPrint.spaces(out, indent); 111 out.print("Exc Range:"); if (excCatchType == null) 113 out.print("any"); else 115 out.print("'" + excCatchType.asString() + "'"); out.print(" start = " + Integer.toString(excStartPC.offset())); out.print(" end = " + Integer.toString(excEndPC.offset())); out.println(" handle = " + Integer.toString(excHandlerPC.offset())); } 120 } 121 122 | Popular Tags |