Get constant field value.
@param javaClazz QDox class
@param javaField QDox field
@param compileClassLoader Classloader for compile dependencies
@param fieldType Field type
@return Value
555133
@SuppressWarnings("unchecked")
  private <T> T getStaticFieldValue(JavaClass javaClazz, JavaField javaField, ClassLoader compileClassLoader, Class<T> fieldType) {
    try {
      Class<?> clazz = compileClassLoader.loadClass(javaClazz.getFullyQualifiedName());
      Field field = clazz.getField(javaField.getName());
      return (T)field.get(fieldType);
    }
    catch (ClassNotFoundException | NoSuchFieldException | SecurityException | IllegalArgumentException | IllegalAccessException ex) {
      throw new RuntimeException("Unable to get contanst value of field '" + javaClazz.getName() + "#" + javaField.getName() + ":\n" + ex.getMessage(), ex);
    }
  }
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);
            }
        }
    }
814230
public static Object getFieldValue(Object instance, String fieldName) {
		try {
			return PropertyUtils.getProperty(instance, fieldName);
		} catch (IllegalAccessException | InvocationTargetException | NoSuchMethodException e) {
			JK.throww(e);
			return null;
		}
	}
704618
public static Object getFieldValue(Object candidate, Field field) {
        try {
            return ReflectUtils.getValue(ReflectUtils.makeAccessible(field), candidate);
        } catch (Exception e) {
            throw BusinessException.wrap(e, BusinessErrorCode.ERROR_ACCESSING_FIELD)
                    .put("className", candidate.getClass())
                    .put("fieldName", field.getName());
        }
    }
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);
        }
        
    }
1171672
public void loadField(String fieldName,
                          TypeDesc type) {
        getfield(0, Opcode.GETFIELD, constantField(fieldName, type), type);
    }
107377
@SuppressWarnings("unchecked")
  public static <T, O> O getFieldValue(Class<T> clz, T t, String fieldName) throws NoSuchFieldException {
    Field field = clz.getDeclaredField(fieldName);
    field.setAccessible(true);
    try {
      return (O) field.get(t);
    } catch (IllegalAccessException e) {
      throw new IllegalStateException(e);
    }
  }
536623
public static Class<?> getGenericFieldType(Field field) {
        ParameterizedType stringListType = (ParameterizedType) field.getGenericType();
        Class<?> clazz = (Class<?>) stringListType.getActualTypeArguments()[0];
        return clazz;
	}
1018115
public static Field getFieldFromClass(String field, Class<? extends Object> clazz) {
        try {
            return clazz.getDeclaredField(field);
        } catch (Exception e) {
            try {
                return clazz.getField(field);
            } catch (Exception ex) {
            }
        }
        return null;
    }
747147
public void addField(String fieldName, String type, short flags,
        int value) {
        short fieldNameIndex = itsConstantPool.addUtf8(fieldName);
        short typeIndex = itsConstantPool.addUtf8(type);
        ClassFileField field = new ClassFileField(fieldNameIndex, typeIndex,
            flags);
        field.setAttributes(itsConstantPool.addUtf8("ConstantValue"),
            (short) 0,
            (short) 0,
            itsConstantPool.addConstant(value));
        itsFields.add(field);
    }
331333
public static Object getDeclaredFieldValue(Object object, String declaredFieldName)
			throws Exception
	{
		Field field = object.getClass().getDeclaredField(declaredFieldName);

		field.setAccessible(true);

		return field.get(object);
	}
862342
public static Object getFieldValue(String qualifiedFieldName) {
		Class clazz;
		try {
			clazz = classForName(ClassUtils.qualifier(qualifiedFieldName));
		}
		catch (ClassNotFoundException cnfe) {
			return null;
		}
		try {
			return clazz.getField(ClassUtils.unqualify(qualifiedFieldName)).get(null);
		}
		catch (Exception e) {
			return null;
		}
	}
331889
public static String constantValue(int index, ConstantPool cp) {
        Constant type = cp.getConstant(index);
        if (type != null) {
            switch (type.getTag()) {
            case Constants.CONSTANT_Class:
                ConstantClass cls = (ConstantClass) type;
                return constantValue(cls.getNameIndex(), cp);

            case Constants.CONSTANT_Double:
                ConstantDouble dbl = (ConstantDouble) type;
                return String.valueOf(dbl.getBytes());

            case Constants.CONSTANT_Fieldref:
                ConstantFieldref fieldRef = (ConstantFieldref) type;
                return constantValue(fieldRef.getClassIndex(), cp) + " "
                        + constantValue(fieldRef.getNameAndTypeIndex(), cp);

            case Constants.CONSTANT_Float:
                ConstantFloat flt = (ConstantFloat) type;
                return String.valueOf(flt.getBytes());

            case Constants.CONSTANT_Integer:
                ConstantInteger integer = (ConstantInteger) type;
                return String.valueOf(integer.getBytes());

            case Constants.CONSTANT_InterfaceMethodref:
                ConstantInterfaceMethodref intRef = (ConstantInterfaceMethodref) type;
                return constantValue(intRef.getClassIndex(), cp) + " "
                        + constantValue(intRef.getNameAndTypeIndex(), cp);

            case Constants.CONSTANT_Long:
                ConstantLong lng = (ConstantLong) type;
                return String.valueOf(lng.getBytes());

            case Constants.CONSTANT_Methodref:
                ConstantMethodref methRef = (ConstantMethodref) type;
                return constantValue(methRef.getClassIndex(), cp) + " "
                        + constantValue(methRef.getNameAndTypeIndex(), cp);

            case Constants.CONSTANT_NameAndType:
                ConstantNameAndType nameType = (ConstantNameAndType) type;
                return nameType.getName(cp) + " " + nameType.getSignature(cp);

            case Constants.CONSTANT_String:
                ConstantString str = (ConstantString) type;
                return str.getBytes(cp);

            case Constants.CONSTANT_Utf8:
                ConstantUtf8 utf8 = (ConstantUtf8) type;
                return utf8.getBytes();
            }
        }
        return "";
    }
898729
public static Field getField(String fieldName, Class<?> clazz) {
    Field field = null;
    try {
      field = clazz.getDeclaredField(fieldName);
    }
    catch (SecurityException e) {
      throw LOG.unableToAccessField(field, clazz.getName());
    }
    catch (NoSuchFieldException e) {
      // for some reason getDeclaredFields doesnt search superclasses
      // (which getFields() does ... but that gives only public fields)
      Class<?> superClass = clazz.getSuperclass();
      if (superClass != null) {
        return getField(fieldName, superClass);
      }
    }
    return field;
  }
212915
public static FieldNode getField(ClassNode classNode, String fieldName) {
        ClassNode node = classNode;
        Set<String> visited = new HashSet<String>();
        while (node != null) {
            FieldNode fn = node.getDeclaredField(fieldName);
            if (fn != null) return fn;
            ClassNode[] interfaces = node.getInterfaces();
            for (ClassNode iNode : interfaces) {
                if (visited.contains(iNode.getName())) continue;
                FieldNode ifn = getField(iNode, fieldName);
                visited.add(iNode.getName());
                if (ifn != null) return ifn;
            }
            node = node.getSuperClass();
        }
        return null;
    }
277018
public static Object getValue(Object instance, String fieldName) {
      Field f = findFieldRecursively(instance.getClass(), fieldName);
      if (f == null) throw new CacheException("Could not find field named '" + fieldName + "' on instance " + instance);
      try {
         f.setAccessible(true);
         return f.get(instance);
      } catch (IllegalAccessException iae) {
         throw new CacheException("Cannot access field " + f, iae);
      }
   }
119997
protected FieldMetadata getFieldMetadataFrom( FieldDeclaration fieldDeclaration ) {
        if (fieldDeclaration != null && fieldDeclaration.getType() != null && (!fieldDeclaration.fragments().isEmpty())) {
            // type
            Type type = fieldDeclaration.getType();
            // Primitive type
            if (type.isPrimitiveType()) {
                return processPrimitiveType(fieldDeclaration);
            }
            // ParameterizedType
            if (type.isParameterizedType()) {
                return processParameterizedType(fieldDeclaration);
            }
            // SimpleType
            if (type.isSimpleType()) {
                return processSimpleType(fieldDeclaration);
            }
            // ArrayType
            if (type.isArrayType()) {
                return processArrayTypeFrom(fieldDeclaration);
            }
            // QualifiedType
            if (type.isQualifiedType()) {
                // TODO

            }
            // WildcardType
            if (type.isWildcardType()) {
                // TODO
            }
        }
        return null;
    }