KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > eclipse > jdt > internal > core > util > ExceptionTableEntry


1 /*******************************************************************************
2  * Copyright (c) 2000, 2006 IBM Corporation and others.
3  * All rights reserved. This program and the accompanying materials
4  * are made available under the terms of the Eclipse Public License v1.0
5  * which accompanies this distribution, and is available at
6  * http://www.eclipse.org/legal/epl-v10.html
7  *
8  * Contributors:
9  * IBM Corporation - initial API and implementation
10  *******************************************************************************/

11 package org.eclipse.jdt.internal.core.util;
12
13 import org.eclipse.jdt.core.util.ClassFormatException;
14 import org.eclipse.jdt.core.util.IConstantPool;
15 import org.eclipse.jdt.core.util.IConstantPoolConstant;
16 import org.eclipse.jdt.core.util.IConstantPoolEntry;
17 import org.eclipse.jdt.core.util.IExceptionTableEntry;
18
19 /**
20  * This class describes an entry in the exception table attribute according
21  * to the JVM specifications.
22  */

23 public class ExceptionTableEntry
24     extends ClassFileStruct
25     implements IExceptionTableEntry {
26
27     private int startPC;
28     private int endPC;
29     private int handlerPC;
30     private int catchTypeIndex;
31     private char[] catchType;
32     
33     ExceptionTableEntry(byte[] classFileBytes, IConstantPool constantPool, int offset) 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.decodeEntry(this.catchTypeIndex);
40             if (constantPoolEntry.getKind() != IConstantPoolConstant.CONSTANT_Class) {
41                 throw new ClassFormatException(ClassFormatException.INVALID_CONSTANT_POOL_ENTRY);
42             }
43             this.catchType = constantPoolEntry.getClassInfoName();
44         }
45     }
46     /**
47      * @see IExceptionTableEntry#getStartPC()
48      */

49     public int getStartPC() {
50         return this.startPC;
51     }
52
53     /**
54      * @see IExceptionTableEntry#getEndPC()
55      */

56     public int getEndPC() {
57         return this.endPC;
58     }
59
60     /**
61      * @see IExceptionTableEntry#getHandlerPC()
62      */

63     public int getHandlerPC() {
64         return this.handlerPC;
65     }
66
67     /**
68      * @see IExceptionTableEntry#getCatchTypeIndex()
69      */

70     public int getCatchTypeIndex() {
71         return this.catchTypeIndex;
72     }
73
74     /**
75      * @see IExceptionTableEntry#getCatchType()
76      */

77     public char[] getCatchType() {
78         return this.catchType;
79     }
80
81 }
82
Popular Tags