01: /*******************************************************************************
02: * Copyright (c) 2000, 2006 IBM Corporation and others.
03: * All rights reserved. This program and the accompanying materials
04: * are made available under the terms of the Eclipse Public License v1.0
05: * which accompanies this distribution, and is available at
06: * http://www.eclipse.org/legal/epl-v10.html
07: *
08: * Contributors:
09: * IBM Corporation - initial API and implementation
10: *******************************************************************************/package org.eclipse.jdt.internal.core.util;
11:
12: import org.eclipse.jdt.core.util.ClassFormatException;
13: import org.eclipse.jdt.core.util.IConstantPool;
14: import org.eclipse.jdt.core.util.IConstantPoolConstant;
15: import org.eclipse.jdt.core.util.IConstantPoolEntry;
16: import org.eclipse.jdt.core.util.IExceptionTableEntry;
17:
18: /**
19: * This class describes an entry in the exception table attribute according
20: * to the JVM specifications.
21: */
22: public class ExceptionTableEntry extends ClassFileStruct implements
23: IExceptionTableEntry {
24:
25: private int startPC;
26: private int endPC;
27: private int handlerPC;
28: private int catchTypeIndex;
29: private char[] catchType;
30:
31: ExceptionTableEntry(byte[] classFileBytes,
32: IConstantPool constantPool, int offset)
33: throws ClassFormatException {
34: this .startPC = u2At(classFileBytes, 0, offset);
35: this .endPC = u2At(classFileBytes, 2, offset);
36: this .handlerPC = u2At(classFileBytes, 4, offset);
37: this .catchTypeIndex = u2At(classFileBytes, 6, offset);
38: if (this .catchTypeIndex != 0) {
39: IConstantPoolEntry constantPoolEntry = constantPool
40: .decodeEntry(this .catchTypeIndex);
41: if (constantPoolEntry.getKind() != IConstantPoolConstant.CONSTANT_Class) {
42: throw new ClassFormatException(
43: ClassFormatException.INVALID_CONSTANT_POOL_ENTRY);
44: }
45: this .catchType = constantPoolEntry.getClassInfoName();
46: }
47: }
48:
49: /**
50: * @see IExceptionTableEntry#getStartPC()
51: */
52: public int getStartPC() {
53: return this .startPC;
54: }
55:
56: /**
57: * @see IExceptionTableEntry#getEndPC()
58: */
59: public int getEndPC() {
60: return this .endPC;
61: }
62:
63: /**
64: * @see IExceptionTableEntry#getHandlerPC()
65: */
66: public int getHandlerPC() {
67: return this .handlerPC;
68: }
69:
70: /**
71: * @see IExceptionTableEntry#getCatchTypeIndex()
72: */
73: public int getCatchTypeIndex() {
74: return this .catchTypeIndex;
75: }
76:
77: /**
78: * @see IExceptionTableEntry#getCatchType()
79: */
80: public char[] getCatchType() {
81: return this.catchType;
82: }
83:
84: }
|