View Javadoc
1   /*
2    * Licensed to the Apache Software Foundation (ASF) under one
3    * or more contributor license agreements.  See the NOTICE file
4    * distributed with this work for additional information
5    * regarding copyright ownership.  The ASF licenses this file
6    * to you under the Apache License, Version 2.0 (the
7    * "License"); you may not use this file except in compliance
8    * with the License.  You may obtain a copy of the License at
9    *
10   *   https://www.apache.org/licenses/LICENSE-2.0
11   *
12   * Unless required by applicable law or agreed to in writing,
13   * software distributed under the License is distributed on an
14   * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
15   * KIND, either express or implied.  See the License for the
16   * specific language governing permissions and limitations
17   * under the License.
18   */
19  package org.apache.bcel.classfile;
20  
21  /**
22   * 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.
23   */
24  public class ClassFormatException extends RuntimeException {
25  
26      private static final long serialVersionUID = -3569097343160139969L;
27  
28      /**
29       * 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
30       * {@link #initCause}.
31       */
32      public ClassFormatException() {
33      }
34  
35      /**
36       * Constructs a new instance with the specified detail message. The cause is not initialized, and may subsequently be initialized by a call to
37       * {@link #initCause}.
38       *
39       * @param message The detail message. The detail message is saved for later retrieval by the {@link #getMessage()} method.
40       */
41      public ClassFormatException(final String message) {
42          super(message);
43      }
44  
45      /**
46       * Constructs a new instance with the specified detail message formatted with See {@link String#format(String, Object...)}.
47       *
48       * @param format See {@link String#format(String, Object...)}.
49       * @param args   See {@link String#format(String, Object...)}.
50       * @since 6.14.0
51       */
52      public ClassFormatException(String format, Object... args) {
53          super(String.format(format, args));
54      }
55  
56      /**
57       * Constructs a new instance with the specified detail message and cause.
58       *
59       * @param message The detail message (which is saved for later retrieval by the {@link #getMessage()} method).
60       * @param cause   The cause (which is saved for later retrieval by the {@link #getCause()} method). A {@code null} value is permitted, and indicates that
61       *                the cause is nonexistent or unknown.
62       * @since 6.0
63       */
64      public ClassFormatException(final String message, final Throwable cause) {
65          super(message, cause);
66      }
67  
68      /**
69       * Constructs a new instance with the specified cause and a detail message of {@code (cause==null ? null : cause.toString())} (which typically contains the
70       * class and detail message of {@code cause}). This constructor is useful for runtime exceptions that are little more than wrappers for other throwables.
71       *
72       * @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
73       *              cause is nonexistent or unknown.
74       * @since 6.7.0
75       */
76      public ClassFormatException(final Throwable cause) {
77          super(cause);
78      }
79  }