/*
* Get the descriptor and then class of the incoming object.
*/
ObjectStreamClass currdesc = currentClassDesc = ObjectStreamClass.lookup(clz);
Class currclass = currentClass = clz;
/* If Externalizable,
* Create an instance and tell it to read its data.
* else,
* Handle it as a serializable class.
*/
if (currentClassDesc.isExternalizable()) {
try {
currentObject = (currentClass == null) ?
null : currentClassDesc.newInstance();
if (currentObject != null) {
// Store this object and its beginning position
// since there might be indirections to it while
// it's been unmarshalled.
activeRecursionMgr.addObject(offset, currentObject);
// Read format version
readFormatVersion();
Externalizable ext = (Externalizable)currentObject;
ext.readExternal(this);
}
} catch (InvocationTargetException e) {
InvalidClassException exc = new InvalidClassException(
currentClass.getName(),
"InvocationTargetException accessing no-arg constructor");
exc.initCause( e ) ;
throw exc ;
} catch (UnsupportedOperationException e) {
InvalidClassException exc = new InvalidClassException(
currentClass.getName(),
"UnsupportedOperationException accessing no-arg constructor");
exc.initCause( e ) ;
throw exc ;
} catch (InstantiationException e) {
InvalidClassException exc = new InvalidClassException(
currentClass.getName(),
"InstantiationException accessing no-arg constructor");
exc.initCause( e ) ;
throw exc ;
}
} else {
/*
* This is your basic diff pattern, made simpler
* because reordering is not allowed.
*/
for (currdesc = currentClassDesc, currclass = currentClass;
currdesc != null && currdesc.isSerializable(); /*sun.4296963 ibm.11861*/
currdesc = currdesc.getSuperclass()) {
/*
* Search the classes to see if the class of this
* descriptor appears further up the hierarchy. Until
* it's found assume its an inserted class. If it's
* not found, its the descriptor's class that has been
* removed.
*/
Class cc = currdesc.forClass();
Class cl;
for (cl = currclass; cl != null; cl = cl.getSuperclass()) {
if (cc == cl) {
// found a superclass that matches this descriptor
break;