Class InvocationTargetException in java

digitization, transformation, binary

Class InvocationTargetException in java

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.

Ads code goes here
public class java.lang.reflect.InvocationTargetException extends java.lang.Exception{
// Public Constructors
public InvocationTargetException(Throwable target);
public InvocationTargetException(Throwable target, String s);
// Protected Constructor
protected InvocationTargetException();
// Public Instance Methods
public Throwable getTargetException();
}

The details of the class structure are given as follows:

protected InvocationTargetException();

protected InvocationTargetException() constructor creates an InvocationTargetException.

public InvocationTargetException(Throwable target);

public InvocationTargetException(Throwable target) constructor creates an InvocationTargetException around the given exception with no associated detail message.

Parameter
target – The exception thrown by the target constructor or method.

public InvocationTargetException(Throwable target, String s);

public InvocationTargetException(Throwable target, String s) constructor creates an InvocationTargetException around the given exception with the given detail message.

Parameter
target – The exception thrown by the target constructor or method.
s – A detail message.

public Throwable getTargetException();

public Throwable getTargetException() method returns the exception that was originally thrown by the constructor or method.

This method returns the exception thrown by the target constructor or method.

The class InvocationTargetException also inherits methods from class Object and Throwable.

From Object classFrom Throwable class
clone()fillInStackTrace()
getClass()getMessage()
notify()printStackTrace()
wait()printStackTrace(PrintWriter)
wait(long, int)getLocalizedMessage()
wait(long)printStackTrace(PrintStream)
equals(Object)
toString()
finalize()
hashCode()
notifyAll()

Leave a Comment

Your email address will not be published. Required fields are marked *