模块 java.base

类 UndeclaredThrowableException

所有已实现的接口:
Serializable

public class UndeclaredThrowableException extends RuntimeException
如果代理实例的调用处理程序的 invoke 方法抛出已检查异常(不可分配给 RuntimeExceptionErrorThrowable ),则由代理实例上的方法调用抛出,该异常类型不可分配给方法的 throws 子句中声明的任何异常类型在代理实例上调用并分派给调用处理程序。

UndeclaredThrowableException 实例包含调用处理程序抛出的未声明的已检查异常,可以使用 getUndeclaredThrowable() 方法检索它。 UndeclaredThrowableException extends RuntimeException ,所以它是一个未检查的异常,它包装了一个已检查的异常。

自从:
1.3
参见:
  • 构造方法详细信息

    • UndeclaredThrowableException

      public UndeclaredThrowableException(Throwable  undeclaredThrowable)
      用指定的 Throwable 构造一个 UndeclaredThrowableException
      参数:
      undeclaredThrowable - 抛出的未声明的已检查异常
    • UndeclaredThrowableException

      public UndeclaredThrowableException(Throwable  undeclaredThrowable, String  s)
      使用指定的 Throwable 和详细消息构造一个 UndeclaredThrowableException
      参数:
      undeclaredThrowable - 抛出的未声明的已检查异常
      s - 详细信息
  • 方法详情

    • getUndeclaredThrowable

      public Throwable  getUndeclaredThrowable()
      返回包装在这个 UndeclaredThrowableException 中的 Throwable 实例,它可能是 null
      API 注意:
      此方法早于通用异常链接工具。 Throwable.getCause() 方法现在是获取此信息的首选方法。
      返回:
      抛出的未声明的已检查异常