From fcffb5ea0b1c2f8aef9c2237f0fc5a809ffc2003 Mon Sep 17 00:00:00 2001 From: tromey Date: Sat, 15 Jun 2002 18:59:15 +0000 Subject: * java/io/BufferedOutputStream.java: Re-merged with Classpath. * java/io/CharConversionException.java: Likewise. * java/io/EOFException.java: Likewise. * java/io/FileNotFoundException.java: Likewise. * java/io/IOException.java: Likewise. * java/io/InterruptedIOException.java: Likewise. * java/io/InvalidClassException.java: Likewise. * java/io/InvalidObjectException.java: Likewise. * java/io/NotActiveException.java: Likewise. * java/io/NotSerializableException.java: Likewise. * java/io/ObjectStreamException.java: Likewise. * java/io/ObjectStreamConstants.java: Likewise. * java/io/OptionalDataException.java: Likewise. * java/io/PipedInputStream.java: Likewise. * java/io/PushbackInputStream.java: Likewise. * java/io/StreamCorruptedException.java: Likewise. * java/io/SyncFailedException.java: Likewise. * java/io/UTFDataFormatException.java: Likewise. * java/io/UnsupportedEncodingException.java: Likewise. * java/io/WriteAbortedException.java: Likewise. git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@54655 138bc75d-0d04-0410-961f-82ee72b054a4 --- libjava/java/io/WriteAbortedException.java | 121 ++++++++++++++++------------- 1 file changed, 65 insertions(+), 56 deletions(-) (limited to 'libjava/java/io/WriteAbortedException.java') diff --git a/libjava/java/io/WriteAbortedException.java b/libjava/java/io/WriteAbortedException.java index ce824a94c98..0204862ef14 100644 --- a/libjava/java/io/WriteAbortedException.java +++ b/libjava/java/io/WriteAbortedException.java @@ -1,6 +1,5 @@ -/* WriteAbortedException.java -- An exception occurred while writing a - serialization stream - Copyright (C) 1998, 2000 Free Software Foundation, Inc. +/* WriteAbortedException.java -- wraps an exception thrown while writing + Copyright (C) 1998, 2000, 2002 Free Software Foundation, Inc. This file is part of GNU Classpath. @@ -8,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 @@ -40,61 +39,71 @@ exception statement from your version. */ package java.io; /** - * This exception is thrown when one of the other ObjectStreamException - * subclasses was thrown during a serialization write. - * - * @version 0.0 + * This exception is thrown when another ObjectStreamException occurs during + * a serialization read or write. The stream is reset, and deserialized + * objects are discarded. * * @author Aaron M. Renn (arenn@urbanophile.com) + * @author Eric Blake + * @since 1.1 + * @status updated to 1.4 */ public class WriteAbortedException extends ObjectStreamException { - -/* - * Instance Variables - */ - -/** - * The detailed exception that caused this exception to be thrown - */ -public Exception detail; -private transient String message; - -/*************************************************************************/ - -/* - * Constructors - */ - -/** - * Create a new WriteAbortedException with an eof parameter indicating - * the detailed Exception that caused this exception to be thrown. - * - * @param detail The exception that caused this exception to be thrown - */ -public -WriteAbortedException(String msg, Exception detail) -{ - this.message = msg; - this.detail = detail; -} - -/*************************************************************************/ - -/* - * Instance Variables - */ - -/** - * This method returns a message indicating what went wrong, including - * the message text from the initial exception that caused this one to - * be thrown - */ -public String -getMessage() -{ - return(message + ": " + detail.getMessage()); -} - + /** + * Compatible with JDK 1.1+. + */ + private static final long serialVersionUID = -3326426625597282442L; + + /** + * The cause of this exception. This pre-dates the exception chaining + * of Throwable; and although you can change this field, you are wiser + * to leave it alone. + * + * @serial the exception cause + */ + public Exception detail; + + /** + * Create a new WriteAbortedException with a specified message and + * cause. + * + * @param msg the message + * @param detail the cause + */ + public WriteAbortedException(String msg, Exception detail) + { + super(msg); + initCause(detail); + this.detail = detail; + } + + /** + * This method returns a message indicating what went wrong, in this + * format: + * super.getMessage() + (detail == null ? "" : "; " + detail). + * + * @return the chained message + */ + public String getMessage() + { + if (detail == this || detail == null) + return super.getMessage(); + return super.getMessage() + "; " + detail; + } + + /** + * Returns the cause of this exception. Note that this may not be the + * original cause, thanks to the detail field being public + * and non-final (yuck). However, to avoid violating the contract of + * Throwable.getCause(), this returns null if detail == this, + * as no exception can be its own cause. + * + * @return the cause + * @since 1.4 + */ + public Throwable getCause() + { + return detail == this ? null : detail; + } } // class WriteAbortedException - -- cgit v1.2.3