Java in a Nutshell, 5th Edition [Electronic resources]

نسخه متنی -صفحه : 1191/ 334
نمايش فراداده

InvocationTargetExceptionjava.lang.reflect

Java 1.1serializable checked

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.

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( )