Convert to a value known because it was returned from a method in a
method property database.

@param field
TODO
964080
public IsNullValue markInformationAsComingFromFieldValue(XField field) {
        if (getBaseKind() == NO_KABOOM_NN) {
            return new IsNullValue(kind | FIELD_VAL, locationOfKaBoom);
        }
        return instanceByFlagsList[(getFlags() | FIELD_VAL) >> FLAG_SHIFT][getBaseKind()];
    }
1116552
public static String getRepeatedEnumValueSetterName(Field field) {
        if (field.isRepeated()) {
            return SETTER_PREFIX + Formatter.toPascalCase(field.getName()) + VALUE;
        }
        throw new IllegalArgumentException(field.toString());
    }
1178177
private Object getFieldValue(final Field field) {
        Object field_value = AccessController.doPrivileged(new PrivilegedAction<Object>() {
            @Override
            public Object run() {
                try {
                    Object value = field.get(_member);

                    // Don't dump sensitive data
                    boolean sensitive = _member.getClass().isAnnotationPresent(Sensitive.class) || field.isAnnotationPresent(Sensitive.class);
                    if (value != null && sensitive) {
                        value = DataFormatHelper.sensitiveToString(value);
                    }

                    return value;
                } catch (IllegalAccessException e) {
                    // No FFDC code needed - we're in the middle of FFDC'ing!
                    // Should not happen - if it does return a string :-)
                    return "/* Could not access " + field.getName() + " */";
                }
            }
        });
        return field_value;
    }
512216
public void updateField(Field field) {
        this.name = field.getName();
        this.obj = TypeCheckUtil.isObjClass(field);
        this.list = TypeCheckUtil.isListClass(field);
        this.number = TypeCheckUtil.isNumberClass(field);
        this.enumType = field.getType().isEnum();
        this.typeClass = field.getType();
        this.type = field.getType().getSimpleName();

        if (this.list) {
            this.innerClass = ValidationObjUtil.getListInnerClassFromGenericType(field.getGenericType());
            this.type += "<" + this.innerClass.getSimpleName() + ">";
        }
    }
269502
private static String convertFieldValueToString(final JBBPAbstractArrayField<?> field) {
    final StringBuilder result;
    if (field instanceof JBBPFieldArrayBit) {
      final JBBPFieldArrayBit array = (JBBPFieldArrayBit) field;
      result = new StringBuilder(array.size());
      for (final byte b : array.getArray()) {
        result.append((char) (b & 0xFF));
      }
    } else if (field instanceof JBBPFieldArrayByte) {
      final JBBPFieldArrayByte array = (JBBPFieldArrayByte) field;
      result = new StringBuilder(array.size());
      for (final byte b : array.getArray()) {
        result.append((char) (b & 0xFF));
      }
    } else if (field instanceof JBBPFieldArrayUByte) {
      final JBBPFieldArrayUByte array = (JBBPFieldArrayUByte) field;
      result = new StringBuilder(array.size());
      for (final byte b : array.getArray()) {
        result.append((char) (b & 0xFF));
      }
    } else if (field instanceof JBBPFieldArrayShort) {
      final JBBPFieldArrayShort array = (JBBPFieldArrayShort) field;
      result = new StringBuilder(array.size());
      for (final short b : array.getArray()) {
        result.append((char) b);
      }
    } else if (field instanceof JBBPFieldArrayUShort) {
      final JBBPFieldArrayUShort array = (JBBPFieldArrayUShort) field;
      result = new StringBuilder(array.size());
      for (final short b : array.getArray()) {
        result.append((char) b);
      }
    } else {
      result = null;
    }
    return result == null ? null : result.toString();
  }
4478
@Override
    public void set(Object value)
    {
        try
        {
            Object v = ConvertUtility.convert(type, value);
            if (field != null)
            {
                field.set(getBase(), v);
            }
            else
            {
                setter.invoke(getBase(), v);
            }
        }
        catch (IllegalAccessException | IllegalArgumentException | InvocationTargetException ex)
        {
            throw new IllegalArgumentException(ex);
        }
    }
50471
public static void setFieldValue(final Object object, final String fieldName, final Object value) {

        final boolean success = new DerivedClassIterator(object.getClass()) {

            @Override
            protected boolean handleClass(final Class<?> clazz) {
                try {
                    setFieldValue(object, clazz, fieldName, value);
                    return true;
                } catch (final NoSuchFieldException e) {
                    LOG.debug("could not set field " + fieldName + " value " + value, e);

                }
                return false;
            }
        }.iterate();

        if (!success) {
            LOG.warn("could not set field " + fieldName + " value " + value);
        }
    }
756702
@Override
    public Object getField(FieldDescriptor field) {
        checkFieldDescriptor(field);
        Object result = field.getNumber() == 1 ? getKey() : getValue();
        // Convert enums to EnumValueDescriptor.
        if (field.getType() == FieldDescriptor.Type.ENUM) {
            result = field.getEnumType().findValueByNumberCreatingIfUnknown((java.lang.Integer) result);
        }
        return result;
    }
717149
public static String getString(Object from, Field field)
    {
        PropertyAccessor<?> accessor = PropertyAccessorFactory.getPropertyAccessor(field);
        Object object = getObject(from, field);
        return object != null ? accessor.toString(object) : null;
    }
28335
private String getStringValue(Object instance, Field field) throws IllegalAccessException {
    Class<?> fieldType = field.getType();

    // Only support primitive type, boxed type, String and Enum
    Preconditions.checkArgument(
      fieldType.isPrimitive() || Primitives.isWrapperType(fieldType) ||
        String.class.equals(fieldType) || fieldType.isEnum(),
      "Unsupported property type %s of field %s in class %s.",
      fieldType.getName(), field.getName(), field.getDeclaringClass().getName()
    );

    if (!field.isAccessible()) {
      field.setAccessible(true);
    }
    Object value = field.get(instance);
    if (value == null) {
      return null;
    }

    // Key name is "className.fieldName".
    return fieldType.isEnum() ? ((Enum<?>) value).name() : value.toString();
  }
838387
public static Object getFieldValue(Object obj, Field field) throws UtilException {
		if (null == obj || null == field) {
			return null;
		}
		field.setAccessible(true);
		Object result = null;
		try {
			result = field.get(obj);
		} catch (IllegalAccessException e) {
			throw new UtilException(e, "IllegalAccess for {}.{}", obj.getClass(), field.getName());
		}
		return result;
	}
654738
public V getValue(T object) {
        try {
            if (this.getMethod != null) {
                return (V)this.getMethod.invoke(object);
            } else {
                return (V)this.field.get(object);
            }
        } catch (IllegalAccessException e) {
            throw new RuntimeException(e);
        } catch (InvocationTargetException e) {
            throw new RuntimeException(e);
        }
    }
205318
public static Object getFieldValue(Object obj, Field field) {
        Object value = null;
        boolean accessible = field.isAccessible();
        //hack accessibility
        if (!accessible) {
            field.setAccessible(true);
        }
        try {
            value = field.get(obj);
        } catch (IllegalAccessException e) {
            //ignore should not happen as accessibility has been updated to suit assignment
            e.printStackTrace(); // $COVERAGE-IGNORE$
        }
        //restore accessibility
        field.setAccessible(accessible);
        return value;
    }
1182449
public int dataToField(Field field) throws DBException
    {
        return ((BaseBuffer)this.getDataSource()).getNextField((FieldInfo)field, Constants.DISPLAY, Constants.READ_MOVE);
    }
246417
private static void setField(Object object, Object value, Field foundField) {
        foundField.setAccessible(true);
        try {
            int fieldModifiersMask = foundField.getModifiers();
            removeFinalModifierIfPresent(foundField);
            foundField.set(object, value);
            restoreModifiersToFieldIfChanged(fieldModifiersMask, foundField);
        } catch (IllegalAccessException e) {
            throw new RuntimeException("Internal error: Failed to set field in method setInternalState.", e);
        }
    }
1227709
private static Fields toFieldEnum(Field field) {
        Class<?> clazz = field.getType();
        String name = clazz.getSimpleName().toLowerCase();

        if (name.equals("int") || name.equals("integer")) {
            return Fields.INT;
        } else if (name.equals("long")) {
            return Fields.LONG;
        } else if (name.equals("float")) {
            return Fields.FLOAT;
        } else if (name.equals("double")) {
            return Fields.DOUBLE;
        } else if (CharSequence.class.isAssignableFrom(clazz)) {
            return Fields.STRING;
        } else if (name.equals("boolean")) {
            return Fields.BOOLEAN;
        } else if (clazz.isAssignableFrom(List.class)) {
            ParameterizedType listType = (ParameterizedType) field.getGenericType();
            Class<?> listClass = (Class<?>) listType.getActualTypeArguments()[0];

            if (listClass.toString().equals("class java.lang.String")) {
                return Fields.LIST;
            }
        }

        throw new RuntimeException("Field not found!");
    }
20785
private static void setListParam(Field field, List<?> values) {
        try {
            // Find method: clear() and call it
            Class<?> fieldClass = field.getType();
            Method clearMethod = fieldClass.getMethod("clear");
            clearMethod.invoke(field.get(config));
            
            // Find List method: add(Object) 
            Method addMethod = fieldClass.getMethod("add", Object.class);
            
            // Add each map key/value to field value
            for (Object subParam : values) {
                if (subParam instanceof String) {
                    addMethod.invoke(field.get(config), subParam);
                } else {
                    throw new RuntimeException("Unexpected parameter type for '" + field.getName() + ":" + subParam);
                }
            }
        } catch (NoSuchMethodException  | IllegalArgumentException | InvocationTargetException | IllegalAccessException e) {
            throw new RuntimeException("Error setting configuration parameter '" + field.getName() + "'", e);
        }
    }