    001/*
    002 * Licensed to the Apache Software Foundation (ASF) under one
    003 * or more contributor license agreements.  See the NOTICE file
    004 * distributed with this work for additional information
    005 * regarding copyright ownership.  The ASF licenses this file
    006 * to you under the Apache License, Version 2.0 (the
    007 * "License"); you may not use this file except in compliance
    008 * with the License.  You may obtain a copy of the License at
    009 *
    010 *   https://www.apache.org/licenses/LICENSE-2.0
    011 *
    012 * Unless required by applicable law or agreed to in writing,
    013 * software distributed under the License is distributed on an
    014 * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
    015 * KIND, either express or implied.  See the License for the
    016 * specific language governing permissions and limitations
    017 * under the License.
    018 */
    019package org.apache.bcel.verifier.structurals;
    020
    021import org.apache.bcel.generic.InstructionHandle;
    022import org.apache.bcel.generic.ObjectType;
    023
    024/**
    025 * This class represents an exception handler; that is, an ObjectType representing a subclass of {@link Throwable} and
    026 * the instruction the handler starts off (represented by an InstructionContext).
    027 */
    028public class ExceptionHandler {
    029
    030    static final ExceptionHandler[] EMPTY_ARRAY = {};
    031
    032    /** The type of the exception to catch. NULL means ANY. */
    033    private final ObjectType catchType;
    034
    035    /** The InstructionHandle where the handling begins. */
    036    private final InstructionHandle handlerPc;
    037
    038    /** Leave instance creation to JustIce. */
    039    ExceptionHandler(final ObjectType catchType, final InstructionHandle handlerPc) {
    040        this.catchType = catchType;
    041        this.handlerPc = handlerPc;
    042    }
    043
    044    /**
    045     * Returns the type of the exception that's handled. <strong>'null' means 'ANY'.</strong>
    046     *
    047     * @return the exception type.
    048     */
    049    public ObjectType getExceptionType() {
    050        return catchType;
    051    }
    052
    053    /**
    054     * Returns the InstructionHandle where the handler starts off.
    055     *
    056     * @return the handler start instruction.
    057     */
    058    public InstructionHandle getHandlerStart() {
    059        return handlerPc;
    060    }
    061}