Name

InvocationTargetException

Synopsis

An object of this class is thrown by Method.invoke( ) and Constructor.newInstance( ) when an exception is thrown by the method or constructor invoked through those methods. The InvocationTargetException class serves as a wrapper around the object that was thrown; that object can be retrieved with the getTargetException( ) method. In Java 1.4 and later, all exceptions can be “chained” in this way, and getTargetException( ) is superseded by the more general getCause( ) method.

java.lang.reflect.InvocationTargetException

Figure 10-96. java.lang.reflect.InvocationTargetException

public class InvocationTargetException extends Exception {
// Public Constructors
     public InvocationTargetException(Throwable target);  
     public InvocationTargetException(Throwable target, String s);  
// Protected Constructors
     protected InvocationTargetException( );  
// Public Instance Methods
     public Throwable getTargetException( );  
// Public Methods Overriding Throwable
                  1.4  public Throwable getCause( );  
}

Thrown By

Constructor.newInstance( ), Method.invoke( )

Get Java in a Nutshell, 5th Edition now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.