java.lang.Objectjava.lang.Throwable
java.lang.Exception
java.lang.reflect.InvocationTargetException
public class InvocationTargetException
InvocationTargetException 是一种包装由调用方法或构造方法所抛出异常的经过检查的异常。
从版本 1.4 开始,此异常已经更新,符合通用异常链机制。“目标异常”是在构造的时候提供的,可以通过 getTargetException() 方法访问,这类对象目前被认为是导致异常的原因,可以通过 Throwable.getCause() 方法以及前面提到的“遗留方法”访问它。
Method,
Constructor,
序列化表格
| 构造方法摘要 | |
|---|---|
protected |
InvocationTargetException() 构造以 null 作为目标异常的 InvocationTargetException。 |
|
InvocationTargetException(Throwable target) 构造带目标异常的 InvocationTargetException。 |
|
InvocationTargetException(Throwable target, String s) 构造带目标异常和详细消息的 InvocationTargetException。 |
| 方法摘要 | |
|---|---|
Throwable |
getCause() 返回此异常的原因(抛出的目标异常,可能为 null)。 |
Throwable |
getTargetException() 获取抛出的目标异常。 |
| 从类 java.lang.Throwable 继承的方法 |
|---|
fillInStackTrace, getLocalizedMessage, getMessage, getStackTrace, initCause, printStackTrace, printStackTrace, printStackTrace, setStackTrace, toString |
| 从类 java.lang.Object 继承的方法 |
|---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait |
| 构造方法详细信息 |
|---|
protected InvocationTargetException()
null 作为目标异常的
InvocationTargetException。
public InvocationTargetException(Throwable target)
target - 目标异常
public InvocationTargetException(Throwable target, String s)
target - 目标异常
s - 详细消息
| 方法详细信息 |
|---|
public Throwable getTargetException()
该方法早于通用异常链设施。Throwable.getCause() 方法现在是获得此信息的首选方法。
public Throwable getCause()