Save This Page
Home » openjdk-7 » java » lang » reflect » [javadoc | source]
java.lang.reflect
public class: UndeclaredThrowableException [javadoc | source]
java.lang.Object
   java.lang.Throwable
      java.lang.Exception
         java.lang.RuntimeException
            java.lang.reflect.UndeclaredThrowableException

All Implemented Interfaces:
    Serializable

Thrown by a method invocation on a proxy instance if its invocation handler's invoke method throws a checked exception (a {@code Throwable} that is not assignable to {@code RuntimeException} or {@code Error}) that is not assignable to any of the exception types declared in the {@code throws} clause of the method that was invoked on the proxy instance and dispatched to the invocation handler.

An {@code UndeclaredThrowableException} instance contains the undeclared checked exception that was thrown by the invocation handler, and it can be retrieved with the {@code getUndeclaredThrowable()} method. {@code UndeclaredThrowableException} extends {@code RuntimeException}, so it is an unchecked exception that wraps a checked exception.

As of release 1.4, this exception has been retrofitted to conform to the general purpose exception-chaining mechanism. The "undeclared checked exception that was thrown by the invocation handler" that may be provided at construction time and accessed via the #getUndeclaredThrowable() method is now known as the cause, and may be accessed via the Throwable#getCause() method, as well as the aforementioned "legacy method."

Field Summary
static final  long serialVersionUID     
Fields inherited from java.lang.RuntimeException:
serialVersionUID
Fields inherited from java.lang.Exception:
serialVersionUID
Constructor:
 public UndeclaredThrowableException(Throwable undeclaredThrowable) 
    Constructs an {@code UndeclaredThrowableException} with the specified {@code Throwable}.
    Parameters:
    undeclaredThrowable - the undeclared checked exception that was thrown
 public UndeclaredThrowableException(Throwable undeclaredThrowable,
    String s) 
    Constructs an {@code UndeclaredThrowableException} with the specified {@code Throwable} and a detail message.
    Parameters:
    undeclaredThrowable - the undeclared checked exception that was thrown
    s - the detail message
Method from java.lang.reflect.UndeclaredThrowableException Summary:
getCause,   getUndeclaredThrowable
Methods from java.lang.Throwable:
addSuppressed,   fillInStackTrace,   getCause,   getLocalizedMessage,   getMessage,   getStackTrace,   getStackTraceDepth,   getStackTraceElement,   getSuppressed,   initCause,   printStackTrace,   printStackTrace,   printStackTrace,   setStackTrace,   toString
Methods from java.lang.Object:
clone,   equals,   finalize,   getClass,   hashCode,   notify,   notifyAll,   toString,   wait,   wait,   wait
Method from java.lang.reflect.UndeclaredThrowableException Detail:
 public Throwable getCause() 
    Returns the cause of this exception (the {@code Throwable} instance wrapped in this {@code UndeclaredThrowableException}, which may be {@code null}).
 public Throwable getUndeclaredThrowable() 
    Returns the {@code Throwable} instance wrapped in this {@code UndeclaredThrowableException}, which may be {@code null}.

    This method predates the general-purpose exception chaining facility. The Throwable#getCause() method is now the preferred means of obtaining this information.