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:
parent
7b518b3953
commit
0cd99be737
4 changed files with 87 additions and 118 deletions
|
@ -199,8 +199,8 @@ public class ObjectInputStream extends InputStream
|
|||
(class_name));
|
||||
}
|
||||
|
||||
setBlockDataMode (true);
|
||||
osc.setClass (resolveClass (osc));
|
||||
Class cl = resolveClass (osc);
|
||||
osc.setClass (cl);
|
||||
setBlockDataMode (false);
|
||||
|
||||
if (this.realInputStream.readByte () != TC_ENDBLOCKDATA)
|
||||
|
@ -487,28 +487,16 @@ public class ObjectInputStream extends InputStream
|
|||
protected Class resolveClass (ObjectStreamClass osc)
|
||||
throws ClassNotFoundException, IOException
|
||||
{
|
||||
// DEBUGln ("Resolving " + osc);
|
||||
|
||||
SecurityManager sm = System.getSecurityManager ();
|
||||
|
||||
if (sm == null)
|
||||
sm = new SecurityManager () {};
|
||||
|
||||
// FIXME: currentClassLoader doesn't yet do anything useful. We need
|
||||
// to call forName() with the classloader of the class which called
|
||||
// readObject(). See SecurityManager.getClassContext().
|
||||
ClassLoader cl = currentClassLoader (sm);
|
||||
|
||||
if (cl == null)
|
||||
{
|
||||
// DEBUGln ("No class loader found");
|
||||
return Class.forName (osc.getName ());
|
||||
}
|
||||
else
|
||||
{
|
||||
// DEBUGln ("Using " + cl);
|
||||
return cl.loadClass (osc.getName ());
|
||||
}
|
||||
return Class.forName (osc.getName (), true, cl);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
Allows subclasses to resolve objects that are read from the
|
||||
stream with other objects to be returned in their place. This
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue