コード例 #1
0
  private void writeExternalData(Externalizable obj) throws IOException {
    Object oldObj = curObj;
    ObjectStreamClass oldDesc = curDesc;
    PutFieldImpl oldPut = curPut;
    curObj = obj;
    curDesc = null;
    curPut = null;

    obj.writeExternal(this);
    dos.writeMarker();

    curObj = oldObj;
    curDesc = oldDesc;
    curPut = oldPut;
  }
コード例 #2
0
 private void writeSerialData(Object obj, ObjectStreamClass desc) throws IOException {
   ObjectStreamClass.ClassDataSlot[] slots = desc.getClassDataLayout();
   for (int i = 0; i < slots.length; i++) {
     ObjectStreamClass slotDesc = slots[i].desc;
     if (slotDesc.hasWriteObjectMethod()) {
       Object oldObj = curObj;
       ObjectStreamClass oldDesc = curDesc;
       PutFieldImpl oldPut = curPut;
       curObj = obj;
       curDesc = slotDesc;
       curPut = null;
       slotDesc.invokeWriteObject(obj, this);
       dos.writeMarker();
       curObj = oldObj;
       curDesc = oldDesc;
       curPut = oldPut;
     } else {
       defaultWriteFields(obj, slotDesc);
     }
   }
 }