summaryrefslogtreecommitdiff
path: root/libjava/java/lang/reflect/InvocationTargetException.java
diff options
context:
space:
mode:
authorTom Tromey <tromey@redhat.com>2002-06-15 19:45:34 +0000
committerTom Tromey <tromey@gcc.gnu.org>2002-06-15 19:45:34 +0000
commit3e1b181a6785c3b77b1cd877a8f6759efad6cfe8 (patch)
tree6325e924516b02fb0d87553b0923dd855f975914 /libjava/java/lang/reflect/InvocationTargetException.java
parent34442f32a2407deff70df24c62713044748caf84 (diff)
downloadgcc-3e1b181a6785c3b77b1cd877a8f6759efad6cfe8.tar.gz
AbstractMethodError.java: Re-merged with Classpath.
* java/lang/AbstractMethodError.java: Re-merged with Classpath. * java/lang/ArithmeticException.java: Likewise. * java/lang/ArrayIndexOutOfBoundsException.java: Likewise. * java/lang/ArrayStoreException.java: Likewise. * java/lang/Byte.java: Likewise. * java/lang/CharSequence.java: Likewise. * java/lang/ClassCastException.java: Likewise. * java/lang/ClassCircularityError.java: Likewise. * java/lang/ClassFormatError.java: Likewise. * java/lang/CloneNotSupportedException.java: Likewise. * java/lang/Cloneable.java: Likewise. * java/lang/Comparable.java: Likewise. * java/lang/Compiler.java: Likewise. * java/lang/Error.java: Likewise. * java/lang/ExceptionInInitializerError.java: Likewise. * java/lang/IllegalAccessError.java: Likewise. * java/lang/IllegalAccessException.java: Likewise. * java/lang/IllegalArgumentException.java: Likewise. * java/lang/IllegalMonitorStateException.java: Likewise. * java/lang/IllegalStateException.java: Likewise. * java/lang/IllegalThreadStateException.java: Likewise. * java/lang/IncompatibleClassChangeError.java: Likewise. * java/lang/IndexOutOfBoundsException.java: Likewise. * java/lang/InheritableThreadLocal.java: Likewise. * java/lang/InstantiationError.java: Likewise. * java/lang/InstantiationException.java: Likewise. * java/lang/InternalError.java: Likewise. * java/lang/InterruptedException.java: Likewise. * java/lang/LinkageError.java: Likewise. * java/lang/NegativeArraySizeException.java: Likewise. * java/lang/NoClassDefFoundError.java: Likewise. * java/lang/NoSuchFieldError.java: Likewise. * java/lang/NoSuchFieldException.java: Likewise. * java/lang/NoSuchMethodError.java: Likewise. * java/lang/NoSuchMethodException.java: Likewise. * java/lang/NullPointerException.java: Likewise. * java/lang/NumberFormatException.java: Likewise. * java/lang/OutOfMemoryError.java: Likewise. * java/lang/Process.java: Likewise. * java/lang/Runnable.java: Likewise. * java/lang/RuntimePermission.java: Likewise. * java/lang/SecurityException.java: Likewise. * java/lang/Short.java: Likewise. * java/lang/StackOverflowError.java: Likewise. * java/lang/StringIndexOutOfBoundsException.java: Likewise. * java/lang/ThreadDeath.java: Likewise. * java/lang/ThreadLocal.java: Likewise. * java/lang/UnknownError.java: Likewise. * java/lang/UnsatisfiedLinkError.java: Likewise. * java/lang/UnsupportedClassVersionError.java: Likewise. * java/lang/UnsupportedOperationException.java: Likewise. * java/lang/VerifyError.java: Likewise. * java/lang/VirtualMachineError.java: Likewise. * java/lang/reflect/InvocationTargetException.java: Likewise. * java/net/BindException.java: Likewise. * java/net/ConnectException.java: Likewise. * java/net/MalformedURLException.java: Likewise. * java/net/NoRouteToHostException.java: Likewise. * java/net/ProtocolException.java: Likewise. * java/net/SocketException.java: Likewise. * java/net/UnknownHostException.java: Likewise. * java/net/UnknownServiceException.java: Likewise. From-SVN: r54656
Diffstat (limited to 'libjava/java/lang/reflect/InvocationTargetException.java')
-rw-r--r--libjava/java/lang/reflect/InvocationTargetException.java142
1 files changed, 63 insertions, 79 deletions
diff --git a/libjava/java/lang/reflect/InvocationTargetException.java b/libjava/java/lang/reflect/InvocationTargetException.java
index 3e7a3d32eb7..904cc631324 100644
--- a/libjava/java/lang/reflect/InvocationTargetException.java
+++ b/libjava/java/lang/reflect/InvocationTargetException.java
@@ -1,5 +1,5 @@
-/* InvocationTargetException.java - Wrapper exception for reflection
- Copyright (C) 1998, 1999, 2000, 2001 Free Software Foundation, Inc.
+/* InvocationTargetException.java -- Wrapper exception for reflection
+ Copyright (C) 1998, 1999, 2000, 2001, 2002 Free Software Foundation, Inc.
This file is part of GNU Classpath.
@@ -7,7 +7,7 @@ GNU Classpath is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation; either version 2, or (at your option)
any later version.
-
+
GNU Classpath is distributed in the hope that it will be useful, but
WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
@@ -38,102 +38,86 @@ exception statement from your version. */
package java.lang.reflect;
-import java.io.PrintStream;
-import java.io.PrintWriter;
-
-/* Written using "Java Class Libraries", 2nd edition, ISBN 0-201-31002-3
- * "The Java Language Specification", ISBN 0-201-63451-1
- * Status: Believed complete and correct.
- */
-
/**
- * InvocationTargetException is sort of a way to "wrap" whatever exception
- * comes up when a method or constructor is called via Reflection.
+ * 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 <code>getTargetException()</code> still works.
*
* @author John Keiser
- * @version 1.1.0, 31 May 1998
* @author Tom Tromey <tromey@cygnus.com>
- * @date December 12, 1998
- *
+ * @author Eric Blake <ebb9@email.byu.edu>
* @see Method#invoke(Object,Object[])
* @see Constructor#newInstance(Object[])
+ * @since 1.1
+ * @status updated to 1.4
*/
-
-public class InvocationTargetException extends Exception
+public class InvocationTargetException extends Exception
{
- static final long serialVersionUID = 4085088731926701167L;
+ /**
+ * Compatible with JDK 1.1+.
+ */
+ private static final long serialVersionUID = 4085088731926701167L;
+
+ /**
+ * The chained exception. This field is only around for serial compatibility.
+ *
+ * @serial the chained exception
+ */
+ private final Throwable target;
- private Throwable target = null;
-
- protected InvocationTargetException()
- {
- super();
- }
-
/**
- * Create an <code>InvocationTargetException</code> using another
+ * Construct an exception with null as the cause. The cause is initialized
+ * to null.
+ */
+ protected InvocationTargetException()
+ {
+ this(null, null);
+ }
+
+ /**
+ * Create an <code>InvocationTargetException</code> using another
* exception.
+ *
* @param targetException the exception to wrap
*/
- public InvocationTargetException(Throwable targetException)
- {
- super(targetException.toString());
- target = targetException;
- }
-
- /**
- * Create an <code>InvocationTargetException</code> using another
+ public InvocationTargetException(Throwable targetException)
+ {
+ this(targetException, null);
+ }
+
+ /**
+ * Create an <code>InvocationTargetException</code> using another
* exception and an error message.
*
* @param targetException the exception to wrap
* @param err an extra reason for the exception-throwing
*/
- public InvocationTargetException(Throwable targetException, String err)
- {
- super(err);
- target = targetException;
- }
-
+ public InvocationTargetException(Throwable targetException, String err)
+ {
+ super(err, targetException);
+ target = targetException;
+ }
+
/**
* Get the wrapped (targeted) exception.
- *
- * @return the targeted exception.
+ *
+ * @return the targeted exception
+ * @see #getCause()
*/
- public Throwable getTargetException()
- {
- return target;
- }
-
- public void printStackTrace()
- {
- if (target == null)
- super.printStackTrace();
- else
- {
- System.err.print(this.getClass() + ": ");
- target.printStackTrace();
- }
- }
-
- public void printStackTrace(PrintStream ps)
- {
- if (target == null)
- super.printStackTrace(ps);
- else
- {
- ps.print(this.getClass() + ": ");
- target.printStackTrace(ps);
- }
- }
+ public Throwable getTargetException()
+ {
+ return target;
+ }
- public void printStackTrace(PrintWriter pw)
- {
- if (target == null)
- super.printStackTrace(pw);
- else
- {
- pw.print(this.getClass() + ": ");
- target.printStackTrace(pw);
- }
- }
+ /**
+ * Returns the cause of this exception (which may be null).
+ *
+ * @return the cause
+ * @since 1.4
+ */
+ public Throwable getCause()
+ {
+ return target;
+ }
}