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 | |
| Constructor: |
public UndeclaredThrowableException(Throwable undeclaredThrowable) {
super((Throwable) null); // Disallow initCause
this.undeclaredThrowable = 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) {
super(s, null); // Disallow initCause
this.undeclaredThrowable = undeclaredThrowable;
}
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
|
| Methods from java.lang.Throwable: |
|---|
|
fillInStackTrace, getCause, getLocalizedMessage, getMessage, getStackTrace, 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() {
return undeclaredThrowable;
}
Returns the cause of this exception (the {@code Throwable}
instance wrapped in this {@code UndeclaredThrowableException},
which may be {@code null}). |
public Throwable getUndeclaredThrowable() {
return undeclaredThrowable;
}
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. |