public class ExceptionInInitializerError extends LinkageError
ExceptionInInitializerError ,以指示在静态初始化程序或静态变量的初始化程序的评估期间发生异常。
从版本1.4开始,这种异常已被改进以符合通用异常链接机制。 可以在施工时提供并通过getException()方法访问的“保存的可抛物体”现在被称为原因 ,并且可以通过Throwable.getCause()方法以及前述的“传统方法”来访问。
| Constructor and Description |
|---|
ExceptionInInitializerError()
构造一个
ExceptionInInitializerError与
null作为其详细的消息字符串,没有保存的可抛物体。
|
ExceptionInInitializerError(String s)
构造具有指定的详细消息字符串的ExceptionInInitializerError。
|
ExceptionInInitializerError(Throwable thrown)
|
| Modifier and Type | Method and Description |
|---|---|
Throwable |
getCause()
返回此错误的原因(导致此错误创建的静态初始化期间发生的异常)。
|
Throwable |
getException()
返回在静态初始化期间发生的异常,导致此错误被创建。
|
addSuppressed, fillInStackTrace, getLocalizedMessage, getMessage, getStackTrace, getSuppressed, initCause, printStackTrace, printStackTrace, printStackTrace, setStackTrace, toStringpublic ExceptionInInitializerError()
ExceptionInInitializerError与null作为其详细的消息字符串,没有保存的可抛物体。
详细消息是描述此特定异常的字符串。
public ExceptionInInitializerError(Throwable thrown)
ExceptionInInitializerError类,通过保存对Throwable对象的引用,以便稍后通过getException()方法检索 。
详细信息字符串设置为null 。
thrown - 抛出的异常
public ExceptionInInitializerError(String s)
Throwable.getMessage()方法检索 。
没有保存的可抛物体。
s - 详细信息
public Throwable getException()
这种方法早于通用异常链接工具。 Throwable.getCause()方法现在是获取此信息的首选方法。
ExceptionInInitializerError的保存的可抛物体,或
null如果这个
ExceptionInInitializerError没有保存的可抛物体。
Submit a bug or feature
For further API reference and developer documentation, see Java SE Documentation. That documentation contains more detailed, developer-targeted descriptions, with conceptual overviews, definitions of terms, workarounds, and working code examples.
Copyright © 1993, 2014, Oracle and/or its affiliates. All rights reserved.