code: private void writeFieldDescriptors(ObjectStreamClass classDesc, boolean externalizable) throws IOException {
          Class<?> loadedClass = classDesc.forClass();
          ObjectStreamField[] fields = null;
          int fieldCount = 0;
  
          // The fields of String are not needed since Strings are treated as
          // primitive types
          if (!externalizable && loadedClass != ObjectStreamClass.STRINGCLASS) {
              fields = classDesc.fields();
              fieldCount = fields.length;
          }
  
          // Field count
          output.writeShort(fieldCount);
          // Field names
          for (int i = 0; i < fieldCount; i++) {
              ObjectStreamField f = fields[i];
              boolean wasPrimitive = f.writeField(output);
              if (!wasPrimitive) {
                  writeObject(f.getTypeString());
              }
          }
      }
docs: Writes a collection of field descriptors (name, type name, etc) for the
  class descriptor {@code classDesc} (an
  {@code ObjectStreamClass})
  
  @param classDesc
  The class descriptor (an {@code ObjectStreamClass})
  for which to write field information
  @param externalizable
  true if the descriptors are externalizable
  
  @throws IOException
  If an IO exception happened when writing the field
  descriptors.
  
  @see #writeObject(Object)