APIdia Launch Partner
Top Description Fields Constructors Methods
java.lang

public Class ExceptionInInitializerError

extends LinkageError
Class Inheritance
Imports
java.io.IOException, .ObjectInputStream, .ObjectOutputStream, .ObjectStreamField

Signals that an unexpected exception has occurred in a static initializer. An ExceptionInInitializerError is thrown to indicate that an exception occurred during evaluation of a static initializer or the initializer for a static variable.
Author
Frank Yellin
Since
1.1

Field Summary

Modifier and TypeField and Description
private static final ObjectStreamField[]
serialPersistentFields

Serializable fields for ExceptionInInitializerError.

private static final long
serialVersionUID

Hides java.lang.LinkageError.serialVersionUID.

Use serialVersionUID from JDK 1.1.X for interoperability

Constructor Summary

AccessConstructor and Description
public
ExceptionInInitializerError()

Constructs an ExceptionInInitializerError with null as its detail message string and with no saved throwable object.

public
ExceptionInInitializerError(Throwable
The exception thrown
thrown
)

Constructs a new ExceptionInInitializerError class by saving a reference to the Throwable object thrown for later retrieval by the getException() method.

public
ExceptionInInitializerError(String
the detail message
s
)

Constructs an ExceptionInInitializerError with the specified detail message string.

Method Summary

Modifier and TypeMethod and Description
public Throwable

Returns:

the saved throwable object of this ExceptionInInitializerError, or null if this ExceptionInInitializerError has no saved throwable object.
getException
()

Returns the exception that occurred during a static initialization that caused this error to be created.

private void
readObject(ObjectInputStream
the ObjectInputStream from which data is read
s
)

Hides java.lang.Throwable.readObject.

Reconstitutes the ExceptionInInitializerError instance from a stream and initialize the cause properly when deserializing from an older version.

private void
writeObject(ObjectOutputStream
the ObjectOutputStream to which data is written
out
)

Hides java.lang.Throwable.writeObject.

To maintain compatibility with older implementation, write a serial "exception" field with the cause as the value.

Field Detail

serialPersistentFieldsback to summary
private static final ObjectStreamField[] serialPersistentFields

Serializable fields for ExceptionInInitializerError.

Annotations
@Serial
Serial Fields:
exception:Throwable
the exception
serialVersionUIDback to summary
private static final long serialVersionUID

Hides java.lang.LinkageError.serialVersionUID.

Use serialVersionUID from JDK 1.1.X for interoperability

Annotations
@Serial

Constructor Detail

ExceptionInInitializerErrorback to summary
public ExceptionInInitializerError()

Constructs an ExceptionInInitializerError with null as its detail message string and with no saved throwable object. A detail message is a String that describes this particular exception.

Annotations
@SuppressWarnings:this-escape
ExceptionInInitializerErrorback to summary
public ExceptionInInitializerError(Throwable thrown)

Constructs a new ExceptionInInitializerError class by saving a reference to the Throwable object thrown for later retrieval by the getException() method. The detail message string is set to null.

Parameters
thrown:Throwable

The exception thrown

ExceptionInInitializerErrorback to summary
public ExceptionInInitializerError(String s)

Constructs an ExceptionInInitializerError with the specified detail message string. A detail message is a String that describes this particular exception. The detail message string is saved for later retrieval by the Throwable#getMessage() method. There is no saved throwable object.

Parameters
s:String

the detail message

Method Detail

getExceptionback to summary
public Throwable getException()

Returns the exception that occurred during a static initialization that caused this error to be created.

API Note

This method predates the general-purpose exception chaining facility. The Throwable#getCause() method is now the preferred means of obtaining this information.

Returns:Throwable

the saved throwable object of this ExceptionInInitializerError, or null if this ExceptionInInitializerError has no saved throwable object.

readObjectback to summary
private void readObject(ObjectInputStream s) throws IOException, ClassNotFoundException

Hides java.lang.Throwable.readObject.

Reconstitutes the ExceptionInInitializerError instance from a stream and initialize the cause properly when deserializing from an older version. The getException and getCause method returns the private "exception" field in the older implementation and ExceptionInInitializerError::cause was set to null.

Parameters
s:ObjectInputStream

the ObjectInputStream from which data is read

Annotations
@Serial
Exceptions
IOException:
if an I/O error occurs
ClassNotFoundException:
if a serialized class cannot be loaded
writeObjectback to summary
private void writeObject(ObjectOutputStream out) throws IOException

Hides java.lang.Throwable.writeObject.

To maintain compatibility with older implementation, write a serial "exception" field with the cause as the value.

Parameters
out:ObjectOutputStream

the ObjectOutputStream to which data is written

Annotations
@Serial
Exceptions
IOException:
if an I/O error occurs