public class InvocationTargetException extends ReflectiveOperationException
在1.4版本中,该异常已被更新以符合通用异常链机制。“目标例外”,在施工时提供的并经getTargetException()
方法访问现在被称为零原因,可通过Throwable.getCause()
方法访问,以及前述的“传统方法”。
方法
,
Constructor
,
Serialized Form
Modifier | Constructor and Description |
---|---|
protected |
InvocationTargetException()
构建一个
InvocationTargetException
null 作为目标的例外。
|
|
InvocationTargetException(Throwable target)
构建一个与目标异常invocationtargetexception。
|
|
InvocationTargetException(Throwable target, String s)
构建一个与目标异常详细信息invocationtargetexception。
|
Modifier and Type | Method and Description |
---|---|
Throwable |
getCause()
返回该异常的原因(抛出的目标异常,这可能是
null )。
|
Throwable |
getTargetException()
获取抛出的目标异常。
|
addSuppressed, fillInStackTrace, getLocalizedMessage, getMessage, getStackTrace, getSuppressed, initCause, printStackTrace, printStackTrace, printStackTrace, setStackTrace, toString
protected InvocationTargetException()
InvocationTargetException
null
作为目标的例外。
public InvocationTargetException(Throwable target)
target
-目标异常
public Throwable getTargetException()
这种方法在通用异常链设施。现在的Throwable.getCause()
方法获取这一信息的首选方式。
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.