001/*
002 * Licensed to the Apache Software Foundation (ASF) under one or more
003 * contributor license agreements.  See the NOTICE file distributed with
004 * this work for additional information regarding copyright ownership.
005 * The ASF licenses this file to You under the Apache License, Version 2.0
006 * (the "License"); you may not use this file except in compliance with
007 * the License.  You may obtain a copy of the License at
008 *
009 *      http://www.apache.org/licenses/LICENSE-2.0
010 *
011 *  Unless required by applicable law or agreed to in writing, software
012 *  distributed under the License is distributed on an "AS IS" BASIS,
013 *  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
014 *  See the License for the specific language governing permissions and
015 *  limitations under the License.
016 */
017package org.apache.bcel.classfile;
018
019/**
020 * Thrown when the BCEL attempts to read a class file and determines that a class is malformed or otherwise cannot be interpreted as a class file.
021 */
022public class ClassFormatException extends RuntimeException {
023
024    private static final long serialVersionUID = -3569097343160139969L;
025
026    /**
027     * Constructs a new instance with {@code null} as its detail message. The cause is not initialized, and may subsequently be initialized by a call to
028     * {@link #initCause}.
029     */
030    public ClassFormatException() {
031    }
032
033    /**
034     * Constructs a new instance with the specified detail message. The cause is not initialized, and may subsequently be initialized by a call to
035     * {@link #initCause}.
036     *
037     * @param message the detail message. The detail message is saved for later retrieval by the {@link #getMessage()} method.
038     */
039    public ClassFormatException(final String message) {
040        super(message);
041    }
042
043    /**
044     * Constructs a new instance with the specified detail message and cause.
045     *
046     * @param message the detail message (which is saved for later retrieval by the {@link #getMessage()} method).
047     * @param cause   the cause (which is saved for later retrieval by the {@link #getCause()} method). A {@code null} value is permitted, and indicates that
048     *                the cause is nonexistent or unknown.
049     * @since 6.0
050     */
051    public ClassFormatException(final String message, final Throwable cause) {
052        super(message, cause);
053    }
054
055    /**
056     * Constructs a new instance with the specified cause and a detail message of {@code (cause==null ? null : cause.toString())} (which typically contains the
057     * class and detail message of {@code cause}). This constructor is useful for runtime exceptions that are little more than wrappers for other throwables.
058     *
059     * @param cause the cause (which is saved for later retrieval by the {@link #getCause()} method). A {@code null} value is permitted, and indicates that the
060     *              cause is nonexistent or unknown.
061     * @since 6.7.0
062     */
063    public ClassFormatException(final Throwable cause) {
064        super(cause);
065    }
066}