1 7 8 package org.gjt.jclasslib.structures.attributes; 9 10 import org.gjt.jclasslib.structures.*; 11 12 import java.io.*; 13 14 20 public class ExceptionTableEntry extends AbstractStructure { 21 22 25 public static final int LENGTH = 8; 26 27 private int startPc; 28 private int endPc; 29 private int handlerPc; 30 private int catchType; 31 32 42 public static ExceptionTableEntry create(DataInput in, ClassFile classFile) 43 throws InvalidByteCodeException, IOException { 44 45 ExceptionTableEntry exceptionTableEntry = new ExceptionTableEntry(); 46 exceptionTableEntry.setClassFile(classFile); 47 exceptionTableEntry.read(in); 48 49 return exceptionTableEntry; 50 } 51 52 55 public ExceptionTableEntry() { 56 } 57 58 66 public ExceptionTableEntry(int startPc, int endPc, int handlerPc, int catchType) { 67 this.startPc = startPc; 68 this.endPc = endPc; 69 this.handlerPc = handlerPc; 70 this.catchType = catchType; 71 } 72 73 78 public int getStartPc() { 79 return startPc; 80 } 81 82 87 public void setStartPc(int startPc) { 88 this.startPc = startPc; 89 } 90 91 96 public int getEndPc() { 97 return endPc; 98 } 99 100 105 public void setEndPc(int endPc) { 106 this.endPc = endPc; 107 } 108 109 114 public int getHandlerPc() { 115 return handlerPc; 116 } 117 118 123 public void setHandlerPc(int handlerPc) { 124 this.handlerPc = handlerPc; 125 } 126 127 132 public int getCatchType() { 133 return catchType; 134 } 135 136 141 public void setCatchType(int catchType) { 142 this.catchType = catchType; 143 } 144 145 public void read(DataInput in) 146 throws InvalidByteCodeException, IOException { 147 148 startPc = in.readUnsignedShort(); 149 endPc = in.readUnsignedShort(); 150 handlerPc = in.readUnsignedShort(); 151 catchType = in.readUnsignedShort(); 152 if (debug) debug("read "); 153 } 154 155 public void write(DataOutput out) 156 throws InvalidByteCodeException, IOException { 157 158 super.write(out); 159 out.writeShort(startPc); 160 out.writeShort(endPc); 161 out.writeShort(handlerPc); 162 out.writeShort(catchType); 163 if (debug) debug("wrote "); 164 } 165 166 protected void debug(String message) { 167 super.debug(message + "exception table entry with start_pc " + startPc + 168 ", end_pc " + endPc + ", handler_pc " + handlerPc + 169 ", catch_type index " + catchType); 170 } 171 172 protected String printAccessFlagsVerbose(int accessFlags) { 173 if (accessFlags != 0) 174 throw new RuntimeException ("Access flags should be zero: " + Integer.toHexString(accessFlags)); 175 return ""; 176 } 177 178 } 179 | Popular Tags |