From 0cd99be7377980b537d5b3a5c1b2903f6b114d9b Mon Sep 17 00:00:00 2001 From: Bryce McKinlay Date: Thu, 26 Apr 2001 02:02:05 +0000 Subject: re PR libgcj/2237 (serialization doesn't throw exception on failure) Fix PR libgcj/2237: * java/io/ObjectStreamClass.java (setClass): Calculate serialVersionUID for local class and compare it against the UID from the Object Stream. Throw InvalidClassException upon mismatch. (setUID): Renamed to... (getClassUID): this. Return the calculated class UID rather than setting uid field directly. (getDefinedSUID): Removed. * java/io/ObjectInputStream.java (resolveClass): Use the three-argument Class.forName(). * java/io/InvalidClassException (toString): Don't include classname in result if it is null. From-SVN: r41567 --- libjava/java/io/InvalidClassException.java | 101 +++++++++++------------------ 1 file changed, 39 insertions(+), 62 deletions(-) (limited to 'libjava/java/io/InvalidClassException.java') diff --git a/libjava/java/io/InvalidClassException.java b/libjava/java/io/InvalidClassException.java index fd03154..1b50bec 100644 --- a/libjava/java/io/InvalidClassException.java +++ b/libjava/java/io/InvalidClassException.java @@ -44,67 +44,44 @@ package java.io; */ public class InvalidClassException extends ObjectStreamException { - -/* - * Instance Variables - */ - -/** - * The name of the class which encountered the error. - */ -public String classname; - -/*************************************************************************/ - -/* - * Constructors - */ - -/** - * Create a new InvalidClassException with a descriptive error message String - * - * @param message The descriptive error message - */ -public -InvalidClassException(String message) -{ - super(message); -} - -/*************************************************************************/ - -/** - * Create a new InvalidClassException with a descriptive error message - * String, and the name of the class that caused the problem. - * - * @param classname The number of bytes tranferred before the interruption - * @param message The descriptive error message - */ -public -InvalidClassException(String classname, String message) -{ - super(message); - this.classname = classname; + /** + * The name of the class which encountered the error. + */ + public String classname; + + /** + * Create a new InvalidClassException with a descriptive error message String + * + * @param message The descriptive error message + */ + public InvalidClassException(String message) + { + super(message); + } + + /** + * Create a new InvalidClassException with a descriptive error message + * String, and the name of the class that caused the problem. + * + * @param classname The number of bytes tranferred before the interruption + * @param message The descriptive error message + */ + public InvalidClassException(String classname, String message) + { + super(message); + this.classname = classname; + } + + /** + * Returns the descriptive error message for this exception. It will + * include the class name that caused the problem if known. This method + * overrides Throwable.getMessage() + * + * @return A descriptive error message + */ + public String getMessage() + { + return super.getMessage() + (classname == null ? "" : ": " + classname); + } } -/*************************************************************************/ - -/* - * Instance Methods - */ - -/** - * Returns the descriptive error message for this exception. It will - * include the class name that caused the problem if known. This method - * overrides Throwable.getMessage() - * - * @return A descriptive error message - */ -public String -getMessage() -{ - return(super.getMessage() + ": " + classname); -} - -} // class InvalidClassException - -- cgit v1.1