java.lang.reflect

Class InvocationTargetException

public class InvocationTargetException extends Exception

InvocationTargetException is sort of a way to "wrap" whatever exception comes up when a method or constructor is called via Reflection. As of JDK 1.4, it was retrofitted to match the exception chaining of all other exceptions, but getTargetException() still works.

Since: 1.1

See Also: Method#invoke(Object,Object[]) Constructor#newInstance(Object[])

UNKNOWN: updated to 1.4

Constructor Summary
protected InvocationTargetException()
Construct an exception with null as the cause.
InvocationTargetException(Throwable targetException)
Create an InvocationTargetException using another exception.
InvocationTargetException(Throwable targetException, String err)
Create an InvocationTargetException using another exception and an error message.
Method Summary
ThrowablegetCause()
Returns the cause of this exception (which may be null).
ThrowablegetTargetException()
Get the wrapped (targeted) exception.

Constructor Detail

InvocationTargetException

protected InvocationTargetException()
Construct an exception with null as the cause. The cause is initialized to null.

InvocationTargetException

public InvocationTargetException(Throwable targetException)
Create an InvocationTargetException using another exception.

Parameters: targetException the exception to wrap

InvocationTargetException

public InvocationTargetException(Throwable targetException, String err)
Create an InvocationTargetException using another exception and an error message.

Parameters: targetException the exception to wrap err an extra reason for the exception-throwing

Method Detail

getCause

public Throwable getCause()
Returns the cause of this exception (which may be null).

Returns: the cause

Since: 1.4

getTargetException

public Throwable getTargetException()
Get the wrapped (targeted) exception.

Returns: the targeted exception

See Also: getCause