01: /*
02: * ProGuard -- shrinking, optimization, obfuscation, and preverification
03: * of Java bytecode.
04: *
05: * Copyright (c) 2002-2007 Eric Lafortune (eric@graphics.cornell.edu)
06: *
07: * This library is free software; you can redistribute it and/or modify it
08: * under the terms of the GNU General Public License as published by the Free
09: * Software Foundation; either version 2 of the License, or (at your option)
10: * any later version.
11: *
12: * This library is distributed in the hope that it will be useful, but WITHOUT
13: * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
14: * FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License
15: * for more details.
16: *
17: * You should have received a copy of the GNU Lesser General Public License
18: * along with this library; if not, write to the Free Software Foundation,
19: * Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
20: */
21: package proguard.classfile.attribute;
22:
23: import proguard.classfile.VisitorAccepter;
24:
25: /**
26: * Representation of an Exception table entry.
27: *
28: * @author Eric Lafortune
29: */
30: public class ExceptionInfo implements VisitorAccepter {
31: public int u2startPC;
32: public int u2endPC;
33: public int u2handlerPC;
34: public int u2catchType;
35:
36: /**
37: * An extra field in which visitors can store information.
38: */
39: public Object visitorInfo;
40:
41: /**
42: * Creates an uninitialized ExceptionInfo.
43: */
44: public ExceptionInfo() {
45: this (0, 0, 0, 0);
46: }
47:
48: /**
49: * Creates an ExceptionInfo with the given properties.
50: */
51: public ExceptionInfo(int u2startPC, int u2endPC, int u2handlerPC,
52: int u2catchType) {
53: this .u2startPC = u2startPC;
54: this .u2endPC = u2endPC;
55: this .u2handlerPC = u2handlerPC;
56: this .u2catchType = u2catchType;
57: }
58:
59: /**
60: * Returns whether the exception's try block contains the instruction at the
61: * given offset.
62: */
63: public boolean isApplicable(int instructionOffset) {
64: return instructionOffset >= u2startPC
65: && instructionOffset < u2endPC;
66: }
67:
68: /**
69: * Returns whether the exception's try block overlaps with the specified
70: * block of instructions.
71: */
72: public boolean isApplicable(int startOffset, int endOffset) {
73: return u2startPC < endOffset && u2endPC > startOffset;
74: }
75:
76: // Implementations for VisitorAccepter.
77:
78: public Object getVisitorInfo() {
79: return visitorInfo;
80: }
81:
82: public void setVisitorInfo(Object visitorInfo) {
83: this.visitorInfo = visitorInfo;
84: }
85: }
|