Class first_nonserial = clazz.getSuperclass(); while (Serializable.class.isAssignableFrom(first_nonserial) || Modifier.isAbstract(first_nonserial.getModifiers())) first_nonserial = first_nonserial.getSuperclass();  osc.firstNonSerializableParent = first_nonserial; osc.realClassIsSerializable = Serializable.class.isAssignableFrom(clazz); osc.realClassIsExternalizable = Externalizable.class.isAssignableFrom(clazz);  ObjectStreamField[] stream_fields = osc.fields; ObjectStreamField[] real_fields = ObjectStreamClass.lookup(clazz).fields; ObjectStreamField[] fieldmapping = new ObjectStreamField[2 * Math.max(stream_fields.length, real_fields.length)]; osc.fieldMapping = fieldmapping;  int stream_idx = 0; int real_idx = 0; int map_idx = 0;  while (stream_idx < stream_fields.length || real_idx < real_fields.length) { ObjectStreamField stream_field = null; ObjectStreamField real_field = null;  if (stream_idx == stream_fields.length) { real_field = real_fields[real_idx++]; } else if (real_idx == real_fields.length) { stream_field = stream_fields[stream_idx++]; } else { int comp_val = real_fields[real_idx].compareTo (stream_fields[stream_idx]);  if (comp_val < 0) { real_field = real_fields[real_idx++]; } else if (comp_val > 0) { stream_field = stream_fields[stream_idx++]; } else { stream_field = stream_fields[stream_idx++]; real_field = real_fields[real_idx++]; if(stream_field.getType() != real_field.getType()) throw new InvalidClassException ("invalid field type for " + real_field.getName() + " in class " + name); } } if (stream_field != null) { if (stream_field.getOffset() < 0) stream_field = null; else if (!stream_field.isToSet()) real_field = null; } if (real_field != null && !real_field.isToSet()) real_field = null; fieldmapping[map_idx++] = stream_field; fieldmapping[map_idx++] = real_field; }
  protected ObjectStreamClass readClassDescriptor()    throws ClassNotFoundException, IOException  {    dumpElement("CLASSDESC NAME=");    String name = this.realInputStream.readUTF();    dumpElement(name + "; UID=");    long uid = this.realInputStream.readLong ();    dumpElement(Long.toHexString(uid) + "; FLAGS=");    byte flags = this.realInputStream.readByte ();    dumpElement(Integer.toHexString(flags) + "; FIELD COUNT=");    short field_count = this.realInputStream.readShort();    dumpElementln(Short.toString(field_count));    ObjectStreamField[] fields = new ObjectStreamField[field_count];    ObjectStreamClass osc = new ObjectStreamClass(name, uid,						  flags, fields);    assignNewHandle(osc);	          for (int i = 0; i < field_count; i++)      {	dumpElement("  TYPE CODE=");	char type_code = (char)this.realInputStream.readByte();	dumpElement(type_code + "; FIELD NAME=");	String field_name = this.realInputStream.readUTF();	dumpElementln(field_name);	String class_name;		  	// If the type code is an array or an object we must	// decode a String here. In the other case we convert	// the type code and pass it to ObjectStreamField.	// Type codes are decoded by gnu.java.lang.reflect.TypeSignature.	if (type_code == 'L' || type_code == '[')	  class_name = (String)readObject();	else	  class_name = String.valueOf(type_code);		  	fields[i] =	  new ObjectStreamField(field_name, class_name, currentLoader());      }	          /* Now that fields have been read we may resolve the class     * (and read annotation if needed). */    Class clazz = resolveClass(osc);        for (int i = 0; i < field_count; i++)      {	Field f;		try	  {	    f = clazz.getDeclaredField(fields[i].getName());	    if (f != null && !f.getType().equals(fields[i].getType()))	      throw new InvalidClassException		("invalid field type for " + fields[i].getName() + " in class "		 + name + " (requested was \"" + fields[i].getType()		 + " and found \"" + f.getType() + "\")"); 	  }	catch (NoSuchFieldException _)	  {	  }      }    boolean oldmode = setBlockDataMode(true);    osc.setClass(clazz, lookupClass(clazz.getSuperclass()));    classLookupTable.put(clazz, osc);    setBlockDataMode(oldmode);    return osc;  }