Returns the value of the given field in the given object using reflection.
357190
public static Object getFieldValue(Field field, Object obj) {
    try {
      return field.get(obj);
    } catch (IllegalAccessException e) {
      throw new IllegalArgumentException(e);
    }
  }
1279237
public function getFieldValue($object, $field)
    {
        $this->assertObjectInstance($object);

        return $this->getField($field)->get($object);
    }
762568
public static JsonObject getObject(JsonObject object, String field) {
        final JsonValue value = object.get(field);
        throwExceptionIfNull(value, field);
        return value.asObject();
    }
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);
        }
    }
115446
@SuppressWarnings("unchecked")
    public static <T> T getValue(Field field, Object self) {
        try {
            return (T) field.get(self);
        } catch (IllegalAccessException e) {
            throw ShedException.wrap(e, ShedErrorCode.UNABLE_TO_GET_FIELD)
                    .put("field", field.toGenericString());
        }
    }
1010733
private static Object reflectObjValue(Object o, String field) throws Exception {
        final Class<?> c = o.getClass();
        final Field f = findField(c, field); //        c.getField(field);
        if (f == null) {
            return null;
        }
        final boolean accessible = f.isAccessible();
        try {
            f.setAccessible(true);
            return f.get(o);
        } finally {
            f.setAccessible(accessible);
        }
    }
692951
@SuppressWarnings("unchecked")
	public <T> T getOne(String field) {
		return (T) get(field).get(field);
	}
1054013
private static Object getFieldValue(FieldClassValue fieldClassValue, Object obj) {
        try {
            return fieldClassValue.get(obj.getClass()).get(obj);
        } catch (IllegalAccessException e) {
            // FieldClassValueFactory returns ClassValue that make the Field
            // accessible, so this should not happen.
            throw new IllegalStateException(e);
        }
    }
331333
public static Object getDeclaredFieldValue(Object object, String declaredFieldName)
			throws Exception
	{
		Field field = object.getClass().getDeclaredField(declaredFieldName);

		field.setAccessible(true);

		return field.get(object);
	}
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;
    }
643437
public static Object getFieldValue(Object obj, String name) {
        Class<?> clazz = obj.getClass();
        try {
            Field f = clazz.getDeclaredField(name);
            return f.get(obj);
        }
        catch (Exception e) {
            return null;
        }
    }
912310
private Object getObjectValue(Node node, String fieldName) {
        // we have to take into account the fact that fieldName will be in the lower case
        if (node != null) {
            String name = node.getLocalName();
            switch (node.getNodeType()) {
                case Node.ATTRIBUTE_NODE:
                    return name.equalsIgnoreCase(fieldName) ? node : null;
                case Node.ELEMENT_NODE: {
                    if (name.equalsIgnoreCase(fieldName)) {
                        return new NodeArray(node.getChildNodes());
                    } else {
                        NamedNodeMap namedNodeMap = node.getAttributes();
                        for (int attributeIndex = 0; attributeIndex < namedNodeMap.getLength(); ++attributeIndex) {
                            Node attribute = namedNodeMap.item(attributeIndex);
                            if (attribute.getLocalName().equalsIgnoreCase(fieldName)) {
                                return attribute;
                            }
                        }
                        return null;
                    }
                }
                default:
                    return null;
            }
        }
        return null;
    }
883971
public static <T> T getFieldValue(final Object obj, final Field field) {
		try {
			return (T) field.get(obj);
		} catch (Exception e) {
			throw convertReflectionExceptionToUnchecked(e);
		}
	}
592137
public static Object getValueOfField(Field field, Object ref) {
		field.setAccessible(true);
		Object value = null;
		try {
			value = field.get(ref);
		} catch (IllegalArgumentException e) {
		} catch (IllegalAccessException e) {
		}
		return value;
	}
1068053
public static <T> T getProperty(Object obj, String propertyName) {
		Method method = getGetterMethod(obj.getClass(), propertyName);
		if (method != null) {
			return invokeMethod(obj, method);
		} else {
			return getFieldValue(obj, propertyName);
		}
	}
15563
public static Object getFieldValue(Object object, String fieldName) {
        try {
            return getDeclaredFieldInHierarchy(object.getClass(), fieldName).get(object);
        } catch (IllegalArgumentException e) {
            throw new RuntimeException(e);
        } catch (IllegalAccessException e) {
            throw new RuntimeException(e);
        }
    }
900564
@Deprecated
    static void field(final Field field, final Object obj, final Object value) throws ReflectiveOperationException {
        if (!field.isAccessible()) {
            field.setAccessible(true);
        }
        final Class<?> type = field.getType();
        if (type.isPrimitive()) {
            if (value == null) {
                // @todo: WARN
                return;
            }
            if (type == boolean.class) {
                field.setBoolean(obj, (Boolean) value);
                return;
            }
            if (type == byte.class) {
                field.setByte(obj, (Byte) value);
                return;
            }
            if (type == char.class) {
                field.setChar(obj, (Character) value);
                return;
            }
            if (type == double.class) {
                field.setDouble(obj, (Double) value);
                return;
            }
            if (type == float.class) {
                field.setFloat(obj, (Float) value);
                return;
            }
            if (type == int.class) {
                field.setInt(obj, (Integer) value);
                return;
            }
            if (type == long.class) {
//                field.setLong(obj, (Long) value);
                if (value instanceof Number) {
                    field.setLong(obj, ((Number) value).longValue());
                    return;
                }
                return;
            }
            if (type == short.class) {
                if (value instanceof Number) {
                    field.setShort(obj, ((Number) value).shortValue());
                    return;
                }
            }
        }
        try {
            field.set(obj, value);
        } catch (final IllegalArgumentException iae) {
            if (type == Boolean.class) {
            }
            if (type == Byte.class) {
            }
            if (type == Short.class) {
                if (value instanceof Number) {
                    field.set(obj, ((Number) value).shortValue());
                    return;
                }
            }
            if (type == Integer.class) {
                if (value instanceof Number) {
                    field.set(obj, ((Number) value).intValue());
                    return;
                }
            }
            if (type == Long.class) {
            }
            if (type == Character.class) {
            }
            if (type == Float.class) {
            }
            if (type == Double.class) {
            }
            throw iae;
        }
    }