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.classfile;
020
021/**
022 * 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.
023 */
024public class ClassFormatException extends RuntimeException {
025
026    private static final long serialVersionUID = -3569097343160139969L;
027
028    /**
029     * 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
030     * {@link #initCause}.
031     */
032    public ClassFormatException() {
033    }
034
035    /**
036     * Constructs a new instance with the specified detail message. The cause is not initialized, and may subsequently be initialized by a call to
037     * {@link #initCause}.
038     *
039     * @param message The detail message. The detail message is saved for later retrieval by the {@link #getMessage()} method.
040     */
041    public ClassFormatException(final String message) {
042        super(message);
043    }
044
045    /**
046     * Constructs a new instance with the specified detail message formatted with See {@link String#format(String, Object...)}.
047     *
048     * @param format See {@link String#format(String, Object...)}.
049     * @param args   See {@link String#format(String, Object...)}.
050     * @since 6.14.0
051     */
052    public ClassFormatException(String format, Object... args) {
053        super(String.format(format, args));
054    }
055
056    /**
057     * Constructs a new instance with the specified detail message and cause.
058     *
059     * @param message The detail message (which is saved for later retrieval by the {@link #getMessage()} method).
060     * @param cause   The cause (which is saved for later retrieval by the {@link #getCause()} method). A {@code null} value is permitted, and indicates that
061     *                the cause is nonexistent or unknown.
062     * @since 6.0
063     */
064    public ClassFormatException(final String message, final Throwable cause) {
065        super(message, cause);
066    }
067
068    /**
069     * Constructs a new instance with the specified cause and a detail message of {@code (cause==null ? null : cause.toString())} (which typically contains the
070     * class and detail message of {@code cause}). This constructor is useful for runtime exceptions that are little more than wrappers for other throwables.
071     *
072     * @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
073     *              cause is nonexistent or unknown.
074     * @since 6.7.0
075     */
076    public ClassFormatException(final Throwable cause) {
077        super(cause);
078    }
079}