code: private ObjectSlot findSlot(String fieldName, Class<?> fieldType) {
          boolean isPrimitive = fieldType != null && fieldType.isPrimitive();
          for (int i = 0; i < slotsToSerialize.length; i++) {
              ObjectSlot slot = slotsToSerialize[i];
              if (slot.field.getName().equals(fieldName)) {
                  if (isPrimitive) {
                      // Looking for a primitive type field. Types must match
                      // *exactly*
                      if (slot.field.getType() == fieldType) {
                          return slot;
                      }
                  } else {
                      // Looking for a non-primitive type field.
                      if (fieldType == null) {
                          return slot; // Null means we take anything
                      }
                      // Types must be compatible (assignment)
                      if (slot.field.getType().isAssignableFrom(fieldType)) {
                          return slot;
                      }
                  }
              }
          }
  
          if (declaredFields != null) {
              for (int i = 0; i < declaredFields.length; i++) {
                  ObjectStreamField field = declaredFields[i];
                  if (field.getName().equals(fieldName)) {
                      if (isPrimitive ? fieldType == field.getType() : fieldType == null ||
                              field.getType().isAssignableFrom(fieldType)) {
                          ObjectSlot slot = new ObjectSlot();
                          slot.field = field;
                          slot.defaulted = true;
                          return slot;
                      }
                  }
              }
          }
          return null;
      }
docs: Finds and returns an ObjectSlot that corresponds to a field named {@code
  fieldName} and type {@code fieldType}. If the field type {@code
  fieldType} corresponds to a primitive type, the field type has to match
  exactly or {@code null} is returned. If the field type {@code fieldType}
  corresponds to an object type, the field type has to be compatible in
  terms of assignment, or null is returned. If {@code fieldType} is {@code
  null}, no such compatibility checking is performed and the slot is
  returned.
  
  @param fieldName
  the name of the field to find
  @param fieldType
  the type of the field. This will be used to test
  compatibility. If {@code null}, no testing is done, the
  corresponding slot is returned.
  @return the object slot, or {@code null} if there is no field with that
  name, or no compatible field (relative to {@code fieldType})