# Class ExceptionInInitializerError

java.lang.Object
java.lang.Throwable
java.lang.Error
java.lang.LinkageError
java.lang.ExceptionInInitializerError

public class ExceptionInInitializerError extends LinkageError

Signals that an unexpected exception has occurred in a static initializer.

Present so an interpreted class initializer can fail the way Java says it fails: the first touch of a class whose `<clinit>` threw reports this, and every touch after it reports NoClassDefFoundError. Without the type, a pushed program's `catch (ExceptionInInitializerError e)` names a class the device does not have.

- ## Constructor Summary

  Constructors
  Constructor
  Description
  `ExceptionInInitializerError()`
  Constructs an ExceptionInInitializerError with no detail message.
  `ExceptionInInitializerError(String s)`
  Constructs an ExceptionInInitializerError with the specified detail message.
  `ExceptionInInitializerError(Throwable thrown)`
  Constructs an ExceptionInInitializerError for the given throwable.

- ## Method Summary

  Modifier and Type
  Method
  Description
  `Throwable`
  `getCause()`
  Same as getException(), for code written against the Throwable API.
  `Throwable`
  `getException()`
  The exception the class initializer threw, or null.

  ### Methods inherited from class Throwable

  `addSuppressed, getLocalizedMessage, getMessage, getStackTrace, getSuppressed, initCause, printStackTrace, printStackTrace, setStackTrace, toString`

  ### Methods inherited from class Object

  `clone, equals, getClass, hashCode, notify, notifyAll, wait, wait, wait`

- ## Constructor Details

  - ### ExceptionInInitializerError

    public ExceptionInInitializerError()
    Constructs an ExceptionInInitializerError with no detail message.

  - ### ExceptionInInitializerError

    public ExceptionInInitializerError(String s)
    Constructs an ExceptionInInitializerError with the specified detail message. s - the detail message.

  - ### ExceptionInInitializerError

    public ExceptionInInitializerError(Throwable thrown)
    Constructs an ExceptionInInitializerError for the given throwable. thrown - the exception the initializer threw.

- ## Method Details

  - ### getException

    public Throwable getException()
    The exception the class initializer threw, or null.

  - ### getCause

    public Throwable getCause()
    Same as getException(), for code written against the Throwable API.
    Overrides:
      `getCause` in class `Throwable`