30 import java.io.ObjectOutputStream; |
30 import java.io.ObjectOutputStream; |
31 import java.io.ObjectStreamField; |
31 import java.io.ObjectStreamField; |
32 |
32 |
33 /** |
33 /** |
34 * Signals that an unexpected exception has occurred in a static initializer. |
34 * Signals that an unexpected exception has occurred in a static initializer. |
35 * An <code>ExceptionInInitializerError</code> is thrown to indicate that an |
35 * An {@code ExceptionInInitializerError} is thrown to indicate that an |
36 * exception occurred during evaluation of a static initializer or the |
36 * exception occurred during evaluation of a static initializer or the |
37 * initializer for a static variable. |
37 * initializer for a static variable. |
38 * |
38 * |
39 * <p>As of release 1.4, this exception has been retrofitted to conform to |
39 * <p>As of release 1.4, this exception has been retrofitted to conform to |
40 * the general purpose exception-chaining mechanism. The "saved throwable |
40 * the general purpose exception-chaining mechanism. The "saved throwable |
52 */ |
52 */ |
53 @java.io.Serial |
53 @java.io.Serial |
54 private static final long serialVersionUID = 1521711792217232256L; |
54 private static final long serialVersionUID = 1521711792217232256L; |
55 |
55 |
56 /** |
56 /** |
57 * Constructs an <code>ExceptionInInitializerError</code> with |
57 * Constructs an {@code ExceptionInInitializerError} with |
58 * <code>null</code> as its detail message string and with no saved |
58 * {@code null} as its detail message string and with no saved |
59 * throwable object. |
59 * throwable object. |
60 * A detail message is a String that describes this particular exception. |
60 * A detail message is a String that describes this particular exception. |
61 */ |
61 */ |
62 public ExceptionInInitializerError() { |
62 public ExceptionInInitializerError() { |
63 initCause(null); // Disallow subsequent initCause |
63 initCause(null); // Disallow subsequent initCause |
64 } |
64 } |
65 |
65 |
66 /** |
66 /** |
67 * Constructs a new <code>ExceptionInInitializerError</code> class by |
67 * Constructs a new {@code ExceptionInInitializerError} class by |
68 * saving a reference to the <code>Throwable</code> object thrown for |
68 * saving a reference to the {@code Throwable} object thrown for |
69 * later retrieval by the {@link #getException()} method. The detail |
69 * later retrieval by the {@link #getException()} method. The detail |
70 * message string is set to <code>null</code>. |
70 * message string is set to {@code null}. |
71 * |
71 * |
72 * @param thrown The exception thrown |
72 * @param thrown The exception thrown |
73 */ |
73 */ |
74 public ExceptionInInitializerError(Throwable thrown) { |
74 public ExceptionInInitializerError(Throwable thrown) { |
75 super(null, thrown); // Disallow subsequent initCause |
75 super(null, thrown); // Disallow subsequent initCause |
95 * <p>This method predates the general-purpose exception chaining facility. |
95 * <p>This method predates the general-purpose exception chaining facility. |
96 * The {@link Throwable#getCause()} method is now the preferred means of |
96 * The {@link Throwable#getCause()} method is now the preferred means of |
97 * obtaining this information. |
97 * obtaining this information. |
98 * |
98 * |
99 * @return the saved throwable object of this |
99 * @return the saved throwable object of this |
100 * <code>ExceptionInInitializerError</code>, or <code>null</code> |
100 * {@code ExceptionInInitializerError}, or {@code null} |
101 * if this <code>ExceptionInInitializerError</code> has no saved |
101 * if this {@code ExceptionInInitializerError} has no saved |
102 * throwable object. |
102 * throwable object. |
103 */ |
103 */ |
104 public Throwable getException() { |
104 public Throwable getException() { |
105 return super.getCause(); |
105 return super.getCause(); |
106 } |
106 } |