Fixing a few bugs in the statistics printout.
[jpf-core.git] / src / main / gov / nasa / jpf / vm / ExceptionHandler.java
1 /*
2  * Copyright (C) 2014, United States Government, as represented by the
3  * Administrator of the National Aeronautics and Space Administration.
4  * All rights reserved.
5  *
6  * The Java Pathfinder core (jpf-core) platform is licensed under the
7  * Apache License, Version 2.0 (the "License"); you may not use this file except
8  * in compliance with the License. You may obtain a copy of the License at
9  * 
10  *        http://www.apache.org/licenses/LICENSE-2.0. 
11  *
12  * Unless required by applicable law or agreed to in writing, software
13  * distributed under the License is distributed on an "AS IS" BASIS,
14  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15  * See the License for the specific language governing permissions and 
16  * limitations under the License.
17  */
18 package gov.nasa.jpf.vm;
19
20 /**
21  * Stores the information about an exception handler.
22  */
23 public class ExceptionHandler {
24   /**
25    * Name of the exception caught. If it is 'null', this means this is an 'any' handler
26    */
27   private String name;
28
29   /**
30    * The first instruction belonging to this handler.
31    */
32   private int begin;
33
34   /**
35    * The last instruction belonging to this handler.
36    */
37   private int end;
38
39   /**
40    * The offset of the handler.
41    */
42   private int handler;
43
44   /**
45    * Creates a new exception handler.
46    */
47   public ExceptionHandler (String n, int b, int e, int h) {
48     name = n;
49     begin = b;
50     end = e;
51     handler = h;
52   }
53
54   /**
55    * Returns the first instruction in the block.
56    */
57   public int getBegin () {
58     return begin;
59   }
60
61   /**
62    * Returns the last instruction in the block.
63    */
64   public int getEnd () {
65     return end;
66   }
67
68   /**
69    * Returns the instruction location for the handler.
70    */
71   public int getHandler () {
72     return handler;
73   }
74
75   /**
76    * Returns the name of the exception caught.
77    */
78   public String getName () {
79     return name;
80   }
81
82
83   @Override
84   public String toString() {
85     return "Handler [name="+name+",from="+begin+",to="+end+",target="+handler+"]";
86   }
87 }