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