cacheMethods();
  void setClass(Class cl, ObjectStreamClass superClass) throws InvalidClassException  {    this.clazz = cl;    long class_uid = getClassUID(cl);    if (uid == 0)      uid = class_uid;    else      {	// Check that the actual UID of the resolved class matches the UID from 	// the stream.    	if (uid != class_uid)	  {	    String msg = cl + 	      ": Local class not compatible: stream serialVersionUID="	      + uid + ", local serialVersionUID=" + class_uid;	    throw new InvalidClassException (msg);	  }      }    isProxyClass = clazz != null && Proxy.isProxyClass(clazz);    this.superClass = superClass;    calculateOffsets();        try      {	ObjectStreamField[] exportedFields = getSerialPersistentFields (clazz);  	if (exportedFields == null)	  return;	ObjectStreamField[] newFieldList = new ObjectStreamField[exportedFields.length + fields.length];	int i, j, k;	/* We now check the import fields against the exported fields.	 * There should not be contradiction (e.g. int x and String x)	 * but extra virtual fields can be added to the class.	 */	Arrays.sort(exportedFields);	i = 0; j = 0; k = 0;	while (i < fields.length && j < exportedFields.length)	  {	    int comp = fields[i].getName().compareTo(exportedFields[j].getName());	    if (comp < 0)	      {		newFieldList[k] = fields[i];		fields[i].setPersistent(false);		fields[i].setToSet(false);		i++;	      }	    else if (comp > 0)	      {		/* field not found in imported fields. We add it		 * in the list of supported fields.		 */		newFieldList[k] = exportedFields[j];		newFieldList[k].setPersistent(true);		newFieldList[k].setToSet(false);		j++;	      }	    else	      {		if (!fields[i].getType().equals(exportedFields[j].getType()))		  throw new InvalidClassException		    ("serialPersistentFields must be compatible with" +		     " imported fields (about " + fields[i].getName() + ")");		newFieldList[k] = fields[i];		fields[i].setPersistent(true);		i++;		j++;	      }	    k++;	  }	if (i < fields.length)	  for (;i<fields.length;i++,k++)	    {	      fields[i].setPersistent(false);	      fields[i].setToSet(false);	      newFieldList[k] = fields[i];	    }	else	  if (j < exportedFields.length)	    for (;j<exportedFields.length;j++,k++)	      {		exportedFields[j].setPersistent(true);		exportedFields[j].setToSet(false);		newFieldList[k] = exportedFields[j];	      }		fields = new ObjectStreamField[k];	System.arraycopy(newFieldList, 0, fields, 0, k);      }    catch (NoSuchFieldException ignore)      {	return;      }    catch (IllegalAccessException ignore)      {	return;      }  }