code: public void setFieldNames(List<String> fieldNames) {
      this.fieldNames = fieldNames;
      if (fields.length != fieldNames.size()) {
        Object[] oldFields = fields;
        fields = new Object[fieldNames.size()];
        System.arraycopy(oldFields, 0, fields, 0,
            Math.min(oldFields.length, fieldNames.size()));
      }
    }
docs: Change the names and number of fields in the struct. No effect if the number of
  fields is the same. The old field values are copied to the new array.
  @param numFields the new number of fields