- java.lang.Object
-
- java.lang.Throwable
-
- java.lang.Exception
-
- java.lang.RuntimeException
-
- java.lang.reflect.UndeclaredThrowableException
-
- All Implemented Interfaces:
-
Serializable
public class UndeclaredThrowableException extends RuntimeException
如果调用处理程序的invoke方法抛出一个检查异常(不能分配给RuntimeException或Error)的异常(Throwable,不能分配给RuntimeException或Error),则在代理实例上的方法调用时抛出,该异常不能分配给方法的throws子句中声明的任何异常类型在代理实例上调用并分派到调用处理程序。一个
UndeclaredThrowableException实例包含调用处理程序抛出的未声明的检查异常,并且可以使用getUndeclaredThrowable()方法检索。UndeclaredThrowableException扩展了RuntimeException,所以它是一个未经检查的异常,包装一个被检查的异常。从版本1.4开始,这种异常已被改进以符合通用异常链接机制。 可以在构建时提供并通过
getUndeclaredThrowable()方法访问的“由调用处理程序抛出的未声明的检查异常”现在被称为原因 ,并且可以通过Throwable.getCause()方法以及上述“传统方法“。- 从以下版本开始:
- 1.3
- 另请参见:
-
InvocationHandler, Serialized Form
-
-
构造方法摘要
构造方法 Constructor 描述 UndeclaredThrowableException(Throwable undeclaredThrowable)构造一个UndeclaredThrowableException与指定的Throwable。UndeclaredThrowableException(Throwable undeclaredThrowable, String s)构造一个UndeclaredThrowableException具有指定Throwable和详细消息。
-
方法摘要
所有方法 接口方法 具体的方法 Modifier and Type 方法 描述 ThrowablegetCause()返回此异常的原因(Throwable实例包装在此UndeclaredThrowableException,可能是null)。ThrowablegetUndeclaredThrowable()返回包含在这个UndeclaredThrowableException中的Throwable实例,可能是null。-
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
-
Methods inherited from class java.lang.Throwable
addSuppressed, fillInStackTrace, getLocalizedMessage, getMessage, getStackTrace, getSuppressed, initCause, printStackTrace, printStackTrace, printStackTrace, setStackTrace, toString
-
-
-
-
构造方法详细信息
-
UndeclaredThrowableException
public UndeclaredThrowableException(Throwable undeclaredThrowable)
构造一个UndeclaredThrowableException与指定的Throwable。- 参数
-
undeclaredThrowable- 抛出的未声明的检查异常
-
-
方法详细信息
-
getUndeclaredThrowable
public Throwable getUndeclaredThrowable()
返回Throwable实例包裹在这个UndeclaredThrowableException,可能是null。这种方法早于通用异常链接工具。
Throwable.getCause()方法现在是获取此信息的首选方法。- 结果
- 未被声明的已检出的异常被抛出
-
-