Generates a getter that get the value by directly accessing the class field.
@param field The reflection field object.
345864
private void directGetter(Field field) {
    GeneratorAdapter mg = new GeneratorAdapter(Opcodes.ACC_PUBLIC, getMethod(Object.class, "get", Object.class),
                                               getterSignature(), new Type[0], classWriter);
    // Simply access by field
    // return ((classType)object).fieldName;
    mg.loadArg(0);
    mg.checkCast(Type.getType(field.getDeclaringClass()));
    mg.getField(Type.getType(field.getDeclaringClass()), field.getName(), Type.getType(field.getType()));
    if (field.getType().isPrimitive()) {
      mg.valueOf(Type.getType(field.getType()));
    }
    mg.returnValue();
    mg.endMethod();
  }
67632
public Object getFieldValue(EntryField field) {
                switch (field) {
                        case TIME:
                                return getTimestamp();
                        case ACTIVITY:
                                return getActivity();
                        case ORIGINATOR:
                                return originator;
                        case EVENTTYPE:
                                return eventType;
                        case META:
                                return Collections.unmodifiableSet(metaData);
                        default:
                                return null;
                }
        }
141777
public static Class[] getGenericTypes(Field field) {
        try {
            ParameterizedType type = (ParameterizedType) field.getGenericType();
            Type[] types = type.getActualTypeArguments();

            Class<?>[] res = new Class<?>[types.length];

            for (int i = 0; i < types.length; i++) {
                res[i] = (Class<?>) types[i];
            }

            return res;

        } catch (ClassCastException e) {
            return new Class<?>[] { (Class<?>) field.getGenericType() };
        }
    }
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);
        }
    }
399320
public static final Object getValue(Object obj, String fieldName) {
        try {
            return getField(obj.getClass(), fieldName).get(obj);
        } catch (IllegalArgumentException e) {
            throw new RuntimeException(e);
        } catch (IllegalAccessException e) {
            throw new RuntimeException(e);
        }
    }
4362
public static Field getField(Class cls, String fieldname) throws NoSuchFieldException
    {
        while (true)
        {
            try
            {
                return cls.getDeclaredField(fieldname);
            }
            catch (NoSuchFieldException ex)
            {
                cls = cls.getSuperclass();
                if (Object.class.equals(cls))
                {
                    throw ex;
                }
            }
            catch (SecurityException ex)
            {
                throw new IllegalArgumentException(ex);
            }
        }
    }
664787
public static <T> T getField(Object obj, String string, Class<?> clazz, Class<T> fieldType) {
		try {
			final Field field = clazz.getDeclaredField(string);
			field.setAccessible(true);
			final Object value = field.get(obj);
			return fieldType.cast(value);
		} catch (Exception exception) {
			throw new Error(exception);
		}
	}
701661
private static CtMethod getFieldGetter(CtField field, CtClass clazz) throws NotFoundException {
        if (field == null) {
            return null;
        }
        return getFieldGetter(field, clazz, false);
    }
473999
public static Field getField(Class clazz, String fieldName) {
        if (Map.class.isAssignableFrom(clazz)) {
            return new Field(new MapField(fieldName));
        }
        java.lang.reflect.Field field = null;
        while (field == null && clazz != null) {
            try {
                field = clazz.getDeclaredField(fieldName);
                field.setAccessible(true);
            } catch (Exception e) {
                clazz = clazz.getSuperclass();
            }
        }
        return new Field(field);
    }
832282
public static Type getPropertyType(Class<?> beanClass, String field) {
		return INSTANCE.findPropertyType(beanClass, field);
	}
954076
public static Object getValue(Field field, Object object) {
		String fieldName = field.getName();
		String setMethodName = "get" + firstLetterUpperCase(fieldName);
		Method method = null;
		try {
			method = object.getClass().getMethod(setMethodName);
		} catch (Exception e) {
		}
		
		if(method != null) {
			try {
				return method.invoke(object);
			} catch (Exception e) {
				LOGGER.error("method invoke", e);
			}
		}
		
		field.setAccessible(true);
		try {
			return field.get(object);
		} catch (Exception e) {
			LOGGER.error("method invoke", e);
			return null;
		}
	}
199330
public static String mapGetByKeyMethodName(Field field) {
        if (field.isMap()) {
            return GETTER_PREFIX + Formatter.toPascalCase(field.getName());
        }
        throw new IllegalArgumentException(field.toString());
    }
1164898
@SuppressWarnings("unchecked")
    public static <T extends Object> T getFieldValue(Object obj, Field field) {
        Assert.notNull(obj, "obj不能为空");
        Assert.notNull(field, "field不能为空");

        try {
            return (T) field.get(obj);
        } catch (IllegalArgumentException e) {
            throw new ReflectException(e);
        } catch (IllegalAccessException e) {
            String msg = StringUtils.format("类型[{0}]的字段[{1}]不允许访问", obj.getClass(),
                field.getName());
            log.error(msg);
            throw new ReflectException(msg, e);
        }
    }
475552
private static Object generateValue(Field field) {
    Class<?> rawType = field.getType();

    //TODO Objects other than Lists might need parametrized types.
    if (List.class.isAssignableFrom(rawType)) {
      ParameterizedType genericType = (ParameterizedType) field.getGenericType();
      return createListObject(genericType);
    }

    return generateValue(rawType);
  }
319533
public Object getFieldValue(final String field) {
        
        final FieldError error = getFirstFieldError(field).orElse(null);
        if(error != null && !error.isConversionFailure()) {
            return error.getRejectedValue();
        } else {
            return getFieldActualValue(field);
        }
        
    }
165661
private void directSetter(Field field) {
    GeneratorAdapter mg = new GeneratorAdapter(Opcodes.ACC_PUBLIC,
                                               getMethod(void.class, "set", Object.class, Object.class),
                                               setterSignature(), new Type[0], classWriter);
    // Simply access by field
    // ((classType)object).fieldName = (valueType)value;
    mg.loadArg(0);
    mg.checkCast(Type.getType(field.getDeclaringClass()));
    mg.loadArg(1);
    if (field.getType().isPrimitive()) {
      mg.unbox(Type.getType(field.getType()));
    } else {
      mg.checkCast(Type.getType(field.getType()));
    }
    mg.putField(Type.getType(field.getDeclaringClass()), field.getName(), Type.getType(field.getType()));
    mg.returnValue();
    mg.endMethod();
  }
448497
public static byte[] get(Object from, Field field)
    {
        PropertyAccessor<?> accessor = PropertyAccessorFactory.getPropertyAccessor(field);
        return accessor.toBytes(getObject(from, field));
    }