1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17 package org.apache.commons.compress.harmony.unpack200.bytecode;
18
19 import java.io.DataOutputStream;
20 import java.io.IOException;
21 import java.util.List;
22
23
24
25
26 public class ExceptionTableEntry {
27
28 private final int startPC;
29 private final int endPC;
30 private final int handlerPC;
31 private final CPClass catchType;
32
33 private int startPcRenumbered;
34 private int endPcRenumbered;
35 private int handlerPcRenumbered;
36 private int catchTypeIndex;
37
38
39
40
41
42
43
44
45
46
47
48
49 public ExceptionTableEntry(final int startPC, final int endPC, final int handlerPC, final CPClass catchType) {
50 this.startPC = startPC;
51 this.endPC = endPC;
52 this.handlerPC = handlerPC;
53 this.catchType = catchType;
54 }
55
56 public CPClass getCatchType() {
57 return catchType;
58 }
59
60 public void renumber(final List<Integer> byteCodeOffsets) {
61 startPcRenumbered = byteCodeOffsets.get(startPC).intValue();
62 final int endPcIndex = startPC + endPC;
63 endPcRenumbered = byteCodeOffsets.get(endPcIndex).intValue();
64 final int handlerPcIndex = endPcIndex + handlerPC;
65 handlerPcRenumbered = byteCodeOffsets.get(handlerPcIndex).intValue();
66 }
67
68 public void resolve(final ClassConstantPool pool) {
69 if (catchType == null) {
70
71
72 catchTypeIndex = 0;
73 return;
74 }
75 catchType.resolve(pool);
76 catchTypeIndex = pool.indexOf(catchType);
77 }
78
79 public void write(final DataOutputStream dos) throws IOException {
80 dos.writeShort(startPcRenumbered);
81 dos.writeShort(endPcRenumbered);
82 dos.writeShort(handlerPcRenumbered);
83 dos.writeShort(catchTypeIndex);
84 }
85 }