diff options
author | tromey <tromey@138bc75d-0d04-0410-961f-82ee72b054a4> | 2002-06-15 19:45:34 +0000 |
---|---|---|
committer | tromey <tromey@138bc75d-0d04-0410-961f-82ee72b054a4> | 2002-06-15 19:45:34 +0000 |
commit | 4a8fcbf1fe2f7cf2c80e4688115c3e49da1c31a9 (patch) | |
tree | 6325e924516b02fb0d87553b0923dd855f975914 /libjava/java/lang/ExceptionInInitializerError.java | |
parent | fcffb5ea0b1c2f8aef9c2237f0fc5a809ffc2003 (diff) | |
download | ppe42-gcc-4a8fcbf1fe2f7cf2c80e4688115c3e49da1c31a9.tar.gz ppe42-gcc-4a8fcbf1fe2f7cf2c80e4688115c3e49da1c31a9.zip |
* 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.
git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@54656 138bc75d-0d04-0410-961f-82ee72b054a4
Diffstat (limited to 'libjava/java/lang/ExceptionInInitializerError.java')
-rw-r--r-- | libjava/java/lang/ExceptionInInitializerError.java | 142 |
1 files changed, 55 insertions, 87 deletions
diff --git a/libjava/java/lang/ExceptionInInitializerError.java b/libjava/java/lang/ExceptionInInitializerError.java index f05a8ca4e6b..d04bdc010d7 100644 --- a/libjava/java/lang/ExceptionInInitializerError.java +++ b/libjava/java/lang/ExceptionInInitializerError.java @@ -1,5 +1,6 @@ -/* ExceptionInInitializerError.java - Copyright (C) 1998, 1999, 2000, 2001 Free Software Foundation, Inc. +/* ExceptionInInitializerError.java -- thrown when class initialization fails + with an uncaught exception + Copyright (C) 1998, 1999, 2000, 2001, 2002 Free Software Foundation, Inc. This file is part of GNU Classpath. @@ -7,7 +8,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,118 +39,85 @@ exception statement from your version. */ package java.lang; -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 - * plus online API docs for JDK 1.2 beta from http://www.javasoft.com. - * Status: Believed complete and correct. - */ - /** - * An <code>ExceptionInInitializerError</code> is thrown when an - * unexpected exception has occurred in a static initializer or the - * initializer for a static variable. + * An <code>ExceptionInInitializerError</code> is thrown when an uncaught + * exception has occurred in a static initializer or the initializer for a + * static variable. In general, this wraps only RuntimeExceptions, since the + * compiler does not allow a checked exception to be uncaught in an + * initializer. This exception only occurs during reflection, when a class + * is initialized as part of another action. * - * @since JDK 1.1 - * * @author Brian Jones * @author Tom Tromey <tromey@cygnus.com> - * @date October 1, 1998 + * @author Eric Blake <ebb9@email.byu.edu> + * @since 1.1 + * @status updated to 1.4 */ public class ExceptionInInitializerError extends LinkageError { + /** + * Compatible with JDK 1.1+. + */ static final long serialVersionUID = 1521711792217232256L; - private Throwable exception = null; + /** + * The cause of this exception (duplicates the one stored in Throwable). + * + * @serial the exception cause + */ + private final Throwable exception; /** - * Create an error without a message. + * Create an error without a message. The cause is initialized as null. */ public ExceptionInInitializerError() - { - super(); - } + { + this((String) null); + } /** - * Create an error with a message. + * Create an error with a message. The cause is initialized as null. + * + * @param s the message */ public ExceptionInInitializerError(String s) - { - super(s); - } + { + super(s); + exception = null; + } /** * Creates an error an saves a reference to the <code>Throwable</code> - * object. + * object. The message string is null. * * @param t the exception thrown */ public ExceptionInInitializerError(Throwable t) - { - super(t.toString()); - exception = t; - } - - /** - * Return the exception that caused this error to be created. - * @return the stored <code>Throwable</code> object or <code>null</code> - * if this <code>ExceptionInInitializerError</code> has no stored - * <code>Throwable</code> object. - */ - public Throwable getException() - { - return exception; - } + { + super(null); + initCause(t); + exception = t; + } /** - * Print a stack trace of the exception that occurred. - */ - public void printStackTrace() - { - if (exception == null) - { - super.printStackTrace(); - } - else - { - System.err.print(this.getClass() + ": "); - exception.printStackTrace(); - } - } - - /** - * Print a stack trace of the exception that occurred to - * the specified <code>PrintStream</code>. + * Return the exception that caused this error to be created. This is a + * legacy method; the preferred choice now is {@link Throwable#getCause()}. + * + * @return the cause, or null if unknown */ - public void printStackTrace(PrintStream ps) - { - if (exception == null) - { - super.printStackTrace(ps); - } - else - { - ps.print(this.getClass() + ": "); - exception.printStackTrace(ps); - } - } + public Throwable getException() + { + return exception; + } /** - * Print a stack trace of the exception that occurred to - * the specified <code>PrintWriter</code>. + * Return the exception that cause this error to be created. + * + * @return the cause, or null if unknown + * @since 1.4 */ - public void printStackTrace(PrintWriter pw) - { - if (exception == null) - { - super.printStackTrace(pw); - } - else - { - pw.print(this.getClass() + ": "); - exception.printStackTrace(pw); - } - } + public Throwable getCause() + { + return exception; + } } |