java.lang.reflect
Class InvocationTargetException
java.lang.Object
|
+--java.lang.Throwable
|
+--java.lang.Exception
|
+--java.lang.reflect.InvocationTargetException
- All Implemented Interfaces:
- java.io.Serializable
- public class InvocationTargetException
- extends java.lang.Exception
InvocationTargetException is a checked exception that wraps
an exception thrown by an invoked method or constructor.
As of release 1.4, this exception has been retrofitted to conform to
the general purpose exception-chaining mechanism. The "target exception"
that is provided at construction time and accessed via the
getTargetException()
method is now known as the cause,
and may be accessed via the Throwable#getCause()
method,
as well as the aforementioned "legacy method."
- See Also:
Method
,
Constructor
, Serialized Form
Constructor Summary |
protected |
InvocationTargetException()
Constructs an InvocationTargetException with
null as the target exception. |
|
InvocationTargetException(java.lang.Throwable target)
Constructs a InvocationTargetException with a target exception. |
|
InvocationTargetException(java.lang.Throwable target,
java.lang.String s)
Constructs a InvocationTargetException with a target exception
and a detail message. |
Method Summary |
java.lang.Throwable |
getCause()
Returns the the cause of this exception (the thrown target exception,
which may be null). |
java.lang.Throwable |
getTargetException()
Get the thrown target exception. |
Methods inherited from class java.lang.Throwable |
fillInStackTrace, getLocalizedMessage, getMessage, printStackTrace, printStackTrace, printStackTrace, toString |
Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait |
InvocationTargetException
protected InvocationTargetException()
- Constructs an
InvocationTargetException
with
null
as the target exception.
InvocationTargetException
public InvocationTargetException(java.lang.Throwable target)
- Constructs a InvocationTargetException with a target exception.
InvocationTargetException
public InvocationTargetException(java.lang.Throwable target,
java.lang.String s)
- Constructs a InvocationTargetException with a target exception
and a detail message.
getTargetException
public java.lang.Throwable getTargetException()
- Get the thrown target exception.
This method predates the general-purpose exception chaining facility.
The Throwable#getCause()
method is now the preferred means of
obtaining this information.
getCause
public java.lang.Throwable getCause()
- Returns the the cause of this exception (the thrown target exception,
which may be null).
- Returns:
- the cause of this exception.
- Since:
- 1.4