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 ;
}
} // end : if (currentClassDesc.isExternalizable())
else {
/* Count number of classes and descriptors we might have
* to work on.
*/
ObjectStreamClass currdesc = currentClassDesc;
Class currclass = currentClass;
int spBase = spClass; // current top of stack
/* The object's classes should be processed from supertype to subtype
* Push all the clases of the current object onto a stack.
* Note that only the serializable classes are represented
* in the descriptor list.
*
* Handle versioning where one or more supertypes of
* have been inserted or removed. The stack will
* contain pairs of descriptors and the corresponding
* class. If the object has a class that did not occur in
* the original the descriptor will be null. If the
* original object had a descriptor for a class not
* present in the local hierarchy of the object the class will be
* null.
*
*/
/*
* This is your basic diff pattern, made simpler
* because reordering is not allowed.
*/
// sun.4296963 ibm.11861
// d11861 we should stop when we find the highest serializable class
// We need this so that when we allocate the new object below, we
// can call the constructor of the non-serializable superclass.
// Note that in the JRMP variant of this code the
// ObjectStreamClass.lookup() method handles this, but we've put
// this fix here rather than change lookup because the new behaviour
// is needed in other cases.
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;
} else {
/* Ignore a class that doesn't match. No
* action is needed since it is already
* initialized.
*/
}
} // end : for (cl = currclass; cl != null; cl = cl.getSuperclass())
/* Test if there is room for this new entry.
* If not, double the size of the arrays and copy the contents.
*/
spClass++;
if (spClass >= classes.length) {
int newlen = classes.length * 2;
Class[] newclasses = new Class[newlen];
ObjectStreamClass[] newclassdesc = new ObjectStreamClass[newlen];
System.arraycopy(classes, 0,
newclasses, 0,
classes.length);
System.arraycopy(classdesc, 0,
newclassdesc, 0,
classes.length);
classes = newclasses;
classdesc = newclassdesc;
}
if (cl == null) {
/* Class not found corresponding to this descriptor.
* Pop off all the extra classes pushed.
* Push the descriptor and a null class.
*/
classdesc[spClass] = currdesc;
classes[spClass] = null;
} else {
/* Current class descriptor matches current class.
* Some classes may have been inserted.
* Record the match and advance the class, continue
* with the next descriptor.
*/
classdesc[spClass] = currdesc;
classes[spClass] = cl;
currclass = cl.getSuperclass();
}
} // end : for (currdesc = currentClassDesc, currclass = currentClass;
/* Allocate a new object. The object is only constructed
* above the highest serializable class and is set to
* default values for all more specialized classes.
*/
try {
currentObject = (currentClass == null) ?
null : currentClassDesc.newInstance() ;
// Store this object and its beginning position
// since there might be indirections to it while
// it's been unmarshalled.
activeRecursionMgr.addObject(offset, currentObject);
} 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 ;
}
/*
* For all the pushed descriptors and classes.