Class ExceptionInInitializerError in Java

Share and Enjoy !

Class ExceptionInInitializerError in Java

ExceptionInInitializerError is thrown by the Java Virtual Machine when an exception occurs in the static initializer of a class. We can use the getException() method to obtain the Throwable object that was thrown from the initializer.

The class structure of class ExceptionInInitializerError is given as

public class java.lang.ExceptionInInitializerError extends java.lang.LinkageError{
// Public Constructors
public ExceptionInInitializerError();
public ExceptionInInitializerError(Throwable thrown);
public ExceptionInInitializerError(String s);
// Public Instance Methods
public Throwable getException();
}

The details of the class structure are given as follows:

public ExceptionInInitializerError();

public ExceptionInInitializerError() constructor creates an ExceptionInInitializerError with no associated detail message.

public ExceptionInInitializerError(Throwable thrown);

public ExceptionInInitializerError(Throwable thrown) constructor creates an ExceptionInInitializerError that refers to the specified exception.
Parameter
thrown -The exception that was thrown in the static initializer.

public ExceptionInInitializerError(String s);

public ExceptionInInitializerError(String s) constructor creates an ExceptionInInitializerError with the specified detail message.
Parameter
s – The detail message.

public Throwable getException();

public Throwable getException() method returns the exception that caused this error to be thrown.
This method returns the exception object that was thrown in the static initializer.
The class ExceptionInInitializerError also inherits methods from class Object and Throwable.

From Object classFrom Throwable class
clone()fillInStackTrace()
getClass()getMessage()
notify()printStackTrace()
wait()printStackTrace(PrintWriter)
wait(long, int)getLocalizedMessage()
wait(long)printStackTrace(PrintStream)
equals(Object)
toString()
finalize()
hashCode()
notifyAll()

Share and Enjoy !

Leave a Reply

Your email address will not be published. Required fields are marked *