code: public void writeExternal(ObjectOutput out) throws IOException {
  
          if (TraceComponent.isAnyTracingEnabled() && tc.isEntryEnabled())
              Tr.entry(tc, "writeExternal");
  
          try {
  
              // write magic
              out.writeShort(EXTERNAL_MAGIC);
              out.writeShort(MAJOR_VERSION);
              out.writeShort(MINOR_VERSION);
  
              // write the interface type (HOME or REMOTE)
              if (_isHome) {
                  out.writeByte(IF_HOME);
              } else {
                  out.writeByte(IF_REMOTE);
              }
  
              //89554
              // write the Java EE name
              writeExternalJ2EEName(out);
  
              // write the external primary key
              writeExternalPKey(out);
              out.flush();
  
          } finally {
              if (TraceComponent.isAnyTracingEnabled() && tc.isEntryEnabled())
                  Tr.exit(tc, "writeExternal");
          }
      }
docs: writeExternal is called by Java serialization when writeObject
  is called on an ObjectOutputStream
  for an object of class BeanId.