View Javadoc
1   /*
2    * Licensed to the Apache Software Foundation (ASF) under one or more
3    * contributor license agreements.  See the NOTICE file distributed with
4    * this work for additional information regarding copyright ownership.
5    * The ASF licenses this file to You under the Apache License, Version 2.0
6    * (the "License"); you may not use this file except in compliance with
7    * the License.  You may obtain a copy of the License at
8    *
9    *      http://www.apache.org/licenses/LICENSE-2.0
10   *
11   *  Unless required by applicable law or agreed to in writing, software
12   *  distributed under the License is distributed on an "AS IS" BASIS,
13   *  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14   *  See the License for the specific language governing permissions and
15   *  limitations under the License.
16   */
17  package org.apache.bcel.verifier.structurals;
18  
19  import org.apache.bcel.generic.InstructionHandle;
20  import org.apache.bcel.generic.ObjectType;
21  
22  /**
23   * This class represents an exception handler; that is, an ObjectType representing a subclass of {@link Throwable} and
24   * the instruction the handler starts off (represented by an InstructionContext).
25   */
26  public class ExceptionHandler {
27  
28      static final ExceptionHandler[] EMPTY_ARRAY = {};
29  
30      /** The type of the exception to catch. NULL means ANY. */
31      private final ObjectType catchType;
32  
33      /** The InstructionHandle where the handling begins. */
34      private final InstructionHandle handlerPc;
35  
36      /** Leave instance creation to JustIce. */
37      ExceptionHandler(final ObjectType catchType, final InstructionHandle handlerPc) {
38          this.catchType = catchType;
39          this.handlerPc = handlerPc;
40      }
41  
42      /**
43       * Returns the type of the exception that's handled. <B>'null' means 'ANY'.</B>
44       */
45      public ObjectType getExceptionType() {
46          return catchType;
47      }
48  
49      /**
50       * Returns the InstructionHandle where the handler starts off.
51       */
52      public InstructionHandle getHandlerStart() {
53          return handlerPc;
54      }
55  }