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
This commit is contained in:
Bryce McKinlay 2001-04-26 02:02:05 +00:00 committed by Bryce McKinlay
parent 7b518b3953
commit 0cd99be737
4 changed files with 87 additions and 118 deletions

View file

@ -44,67 +44,44 @@ package java.io;
*/
public class InvalidClassException extends ObjectStreamException
{
/**
* The name of the class which encountered the error.
*/
public String classname;
/*
* Instance Variables
*/
/**
* Create a new InvalidClassException with a descriptive error message String
*
* @param message The descriptive error message
*/
public InvalidClassException(String message)
{
super(message);
}
/**
* The name of the class which encountered the error.
*/
public String classname;
/**
* 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;
}
/*************************************************************************/
/*
* Constructors
*/
/**
* Create a new InvalidClassException with a descriptive error message String
*
* @param message The descriptive error message
*/
public
InvalidClassException(String message)
{
super(message);
/**
* 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);
}
}
/*************************************************************************/
/**
* 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;
}
/*************************************************************************/
/*
* 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