Gets a field from an object.
@param obj object from which to read the field
@param name the field name to read
485736
public static Object getField(Object obj, String name) {
    try {
      Class<? extends Object> klass = obj.getClass();
      do {
        try {
          Field field = klass.getDeclaredField(name);
          field.setAccessible(true);
          return field.get(obj);
        } catch (NoSuchFieldException e) {
          klass = klass.getSuperclass();
        }
      } while (klass != null);
      throw new RuntimeException(); // true no such field exception
    } catch (SecurityException e) {
      throw new RuntimeException(e);
    } catch (IllegalArgumentException e) {
      throw new RuntimeException(e);
    } catch (IllegalAccessException e) {
      throw new RuntimeException(e);
    }
  }
518436
public String getField(String name, String defaultVal) {
		int index = getFieldIndex(name);
		return (isInRange(index) ? this.fields.get(index) : defaultVal);
	}
1150904
public Field field(String name) {
    for (Field field : declaredFields) {
      if (field.name().equals(name)) {
        return field;
      }
    }
    for (OneOf oneOf : oneOfs) {
      for (Field field : oneOf.fields()) {
        if (field.name().equals(name)) {
          return field;
        }
      }
    }
    return null;
  }
204628
public static Object getFieldValue(final Object obj, final String fieldName) {
		Field field = getAccessibleField(obj, fieldName);

		if (field == null) {
			throw new IllegalArgumentException("Could not find field [" + fieldName + "] on target [" + obj + "]");
		}

		Object result = null;
		try {
			result = field.get(obj);
		} catch (IllegalAccessException e) {
			logger.error("不可能抛出的异常{}", e.getMessage());
		}
		return result;
	}
883971
public static <T> T getFieldValue(final Object obj, final Field field) {
		try {
			return (T) field.get(obj);
		} catch (Exception e) {
			throw convertReflectionExceptionToUnchecked(e);
		}
	}
911722
public void addField(final String name, final Object value) {
        if (value == null) {
            this.fields.add(new Field(name, null, null));
        } else {
            this.fields.add(new Field(name, value.toString(), value.getClass().getName()));
        }
    }
1346956
public FieldNode getDeclaredField(String name) {
        if (redirect != null) return redirect().getDeclaredField(name);

        lazyClassInit();
        return fieldIndex == null ? null : fieldIndex.get(name);
    }
1112459
def get_field(name, model=None):
    
    if '.' in name:
        m, name = name.split('.')
        model = get_model(m)

    if model:
        return getattr(model, name, None)
452733
public static Object getObject(Object from, Field field)
    {
        if (!field.isAccessible())
        {
            field.setAccessible(true);
        }
        try
        {
            return field.get(from);
        }
        catch (IllegalArgumentException iarg)
        {
            throw new PropertyAccessException(iarg);
        }
        catch (IllegalAccessException iacc)
        {
            throw new PropertyAccessException(iacc);
        }
    }
1342007
public JavaField getField(String name)
  {
    ArrayList<JavaField> fieldList = getFieldList();
    
    for (int i = 0; i < fieldList.size(); i++) {
      JavaField field = fieldList.get(i);

      if (field.getName().equals(name))
        return field;
    }

    return null;
  }
810215
public static Variable getVariable(Object object, String name) {
        return getVariable(getThisNS(object), name);
    }
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;
    }
393794
@Override
    public Object getMember(String name) {
        switch (name) {
            case "get":
            case "apply":
                return F_get;
            case "getString":
                return F_getString;
            case "getBinary":
                return F_getBinary;
            case "getBoolean":
                return F_getBoolean;
            case "getDate":
                return F_getDate;
            case "getDouble":
                return F_getDouble;
            case "getFloat":
                return F_getFloat;
            case "getInt":
                return F_getInt;
            case "getAs":
                return F_getAs;
            case "getTimestamp":
                return F_getTimestamp;
            case "getList":
            case "getArray":
                return F_getList;
            case "getStruct":
                return F_getStruct;
            case "mkString":
                return F_mkString;
            case "schema":
                return F_schema;
            case "length":
                return F_length;
            case "size":
                return F_length;
            case "anyNull":
                return F_anyNull;
            case "copy":
                return F_copy;
            case "equals":
                return F_equals;
            case "fieldIndex":
                return F_fieldIndex;
            case "hashCode":
                return F_hashCode;
            case "isNullAt":
                return F_isNullAt;
        }
        return super.getMember(name);
    }
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);
        }
    }
849120
public String getNameByReflection(Object obj)
    {
        Object name = null;
        try {
            java.lang.reflect.Method method = obj.getClass().getMethod("getName");
            
            if (method != null)
                name = method.invoke(obj);
        } catch (Exception e) {
            e.printStackTrace();
        }
        if (name == null)
            return null;
        else
            return name.toString();
    }
679656
Field getField(String name)
    {       
        FieldInfo info=getFieldInfo(name);
        return getField(info,true);
    }
363902
private static Object readFieldValue(final Object obj, final Field field) {
    try {
      return field.get(obj);
    } catch (Exception ex) {
      throw new JBBPException("Can't get value from field [" + field + ']', ex);
    }
  }