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.