java.lang.reflect

Class UndeclaredThrowableException

public class UndeclaredThrowableException extends RuntimeException

This exception class is thrown by a {@link Proxy} instance if the {@link InvocationHandler#invoke(Object, Method, Object[]) invoke} method of that instance's InvocationHandler attempts to throw an exception that not declared by the throws clauses of all of the interface methods that the proxy instance is implementing.

When thrown by Proxy, this class will always wrap a checked exception, never {@link Error} or {@link RuntimeException}, which are unchecked.

Since: 1.3

See Also: Proxy InvocationHandler

UNKNOWN: updated to 1.4

Constructor Summary
UndeclaredThrowableException(Throwable cause)
Wraps the given checked exception into a RuntimeException, with no detail message.
UndeclaredThrowableException(Throwable cause, String message)
Wraps the given checked exception into a RuntimeException, with the specified detail message.
Method Summary
ThrowablegetCause()
Returns the cause of this exception.
ThrowablegetUndeclaredThrowable()
Returns the cause of this exception.

Constructor Detail

UndeclaredThrowableException

public UndeclaredThrowableException(Throwable cause)
Wraps the given checked exception into a RuntimeException, with no detail message. {@link Throwable#initCause(Throwable)} will fail on this instance.

Parameters: cause the undeclared throwable that caused this exception, may be null

UndeclaredThrowableException

public UndeclaredThrowableException(Throwable cause, String message)
Wraps the given checked exception into a RuntimeException, with the specified detail message. {@link Throwable#initCause(Throwable)} will fail on this instance.

Parameters: cause the undeclared throwable that caused this exception, may be null message the message, may be null

Method Detail

getCause

public Throwable getCause()
Returns the cause of this exception. If this exception was created by a {@link Proxy} instance, it will be a non-null checked exception.

Returns: the cause of this exception, may be null

Since: 1.4

getUndeclaredThrowable

public Throwable getUndeclaredThrowable()
Returns the cause of this exception. If this exception was created by a {@link Proxy} instance, it will be a non-null checked exception. This method pre-dates exception chaining, and is now simply a longer way to call getCause().

Returns: the cause of this exception, may be null

See Also: getCause