Changes the access level for the specified field for a class.

@param clazz the clazz
@param fieldName the field name
@param srgName the srg name
@param silenced the silenced
@return the field
544620
public static Field changeFieldAccess(Class<?> clazz, String fieldName, String srgName, boolean silenced)
	{
		try
		{
			Field f = clazz.getDeclaredField(MalisisCore.isObfEnv ? srgName : fieldName);
			f.setAccessible(true);
			Field modifiers = Field.class.getDeclaredField("modifiers");
			modifiers.setAccessible(true);
			modifiers.setInt(f, f.getModifiers() & ~Modifier.FINAL);

			return f;
		}
		catch (ReflectiveOperationException e)
		{
			if (!silenced)
				MalisisCore.log.error("Could not change access for field " + clazz.getSimpleName() + "."
						+ (MalisisCore.isObfEnv ? srgName : fieldName), e);
			return null;
		}

	}
367419
public static Object getStaticFieldValue(Class<?> clazz, String name) {
        Field field = ReflectionUtils.findField(clazz, name);
        if (field != null) {
            ReflectionUtils.makeAccessible(field);
            try {
                return field.get(clazz);
            } catch (IllegalAccessException ignored) {}
        }
        return null;
    }
368050
@Override
    public FieldVisitor visitField(final int access, final String name,
            final String desc, final String signature, final Object value) {
        if (computeSVUID) {
            if ("serialVersionUID".equals(name)) {
                // since the class already has SVUID, we won't be computing it.
                computeSVUID = false;
                hasSVUID = true;
            }
            /*
             * Remember field for SVUID computation For field modifiers, only
             * the ACC_PUBLIC, ACC_PRIVATE, ACC_PROTECTED, ACC_STATIC,
             * ACC_FINAL, ACC_VOLATILE, and ACC_TRANSIENT flags are used when
             * computing serialVersionUID values.
             */
            if ((access & Opcodes.ACC_PRIVATE) == 0
                    || (access & (Opcodes.ACC_STATIC | Opcodes.ACC_TRANSIENT)) == 0) {
                int mods = access
                        & (Opcodes.ACC_PUBLIC | Opcodes.ACC_PRIVATE
                                | Opcodes.ACC_PROTECTED | Opcodes.ACC_STATIC
                                | Opcodes.ACC_FINAL | Opcodes.ACC_VOLATILE | Opcodes.ACC_TRANSIENT);
                svuidFields.add(new Item(name, mods, desc));
            }
        }

        return super.visitField(access, name, desc, signature, value);
    }
589867
public static JMapAccessor getFieldAccessors(Class<?> clazz, Field field){
		return getFieldAccessors(clazz,field,false, field.getName(),Constants.DEFAULT_FIELD_VALUE);
	}
622588
public static void getFields (Class<?> clazz, List<Field> addTo)
    {
        // first get the fields of the superclass
        Class<?> pclazz = clazz.getSuperclass();
        if (pclazz != null && !pclazz.equals(Object.class)) {
            getFields(pclazz, addTo);
        }

        // then reflect on this class's declared fields
        Field[] fields;
        try {
            fields = clazz.getDeclaredFields();
        } catch (SecurityException se) {
            System.err.println("Unable to get declared fields of " + clazz.getName() + ": " + se);
            fields = new Field[0];
        }

        // override the default accessibility check for the fields
        try {
            AccessibleObject.setAccessible(fields, true);
        } catch (SecurityException se) {
            // ah well, only publics for us
        }

        for (Field field : fields) {
            int mods = field.getModifiers();
            if (Modifier.isStatic(mods) || Modifier.isTransient(mods)) {
                continue; // skip static and transient fields
            }
            addTo.add(field);
        }
    }
803864
private Object getFieldValue(Object oldInstance, String fieldName) throws NoSuchFieldException, IllegalAccessException
	{
		Class<? extends Object> c = oldInstance.getClass();
		final Field f = c.getDeclaredField(fieldName);
		AccessController.doPrivileged(new PrivilegedAction<Object>() {
			public Object run()
			{
				f.setAccessible(true);
				return null;
			}
		});
		return f.get(oldInstance);
	}
900493
public static Field[] findFields(Class<?> clazz) throws IllegalAccessException {
        final List<Field> fieldList = new ArrayList<Field>();

        doWithDeclaredFields(clazz, new FieldCallback() {
            public void doWith(Field field) {
                fieldList.add(field);
            }
        });
        return fieldList.toArray(new Field[fieldList.size()]);
    }
377188
@SuppressWarnings("unchecked")
    private void addPrivateFieldsAccessors(ClassNode node) {
        Set<ASTNode> accessedFields = (Set<ASTNode>) node.getNodeMetaData(StaticTypesMarker.PV_FIELDS_ACCESS);
        if (accessedFields==null) return;
        Map<String, MethodNode> privateConstantAccessors = (Map<String, MethodNode>) node.getNodeMetaData(PRIVATE_FIELDS_ACCESSORS);
        if (privateConstantAccessors!=null) {
            // already added
            return;
        }
        int acc = -1;
        privateConstantAccessors = new HashMap<String, MethodNode>();
        final int access = Opcodes.ACC_STATIC | Opcodes.ACC_PUBLIC | Opcodes.ACC_SYNTHETIC;
        for (FieldNode fieldNode : node.getFields()) {
            if (accessedFields.contains(fieldNode)) {

                acc++;
                Parameter param = new Parameter(node.getPlainNodeReference(), "$that");
                Expression receiver = fieldNode.isStatic()?new ClassExpression(node):new VariableExpression(param);
                Statement stmt = new ExpressionStatement(new PropertyExpression(
                        receiver,
                        fieldNode.getName()
                ));
                MethodNode accessor = node.addMethod("pfaccess$"+acc, access, fieldNode.getOriginType(), new Parameter[]{param}, ClassNode.EMPTY_ARRAY, stmt);
                privateConstantAccessors.put(fieldNode.getName(), accessor);
            }
        }
        node.setNodeMetaData(PRIVATE_FIELDS_ACCESSORS, privateConstantAccessors);
    }
365425
public static Field makeAccessible(Field field) {
        if (field == null) {
            throw new IllegalArgumentException("Method argument field must not be null.");
        }
        if (isInaccessible(field) && !field.isAccessible()) {
            field.setAccessible(true);
        }

        return field;
    }
607216
@Check
	public void checkFieldNameShadowing(SarlField field) {
		if (!isIgnored(VARIABLE_NAME_SHADOWING)
				&& !Utils.isHiddenMember(field.getName())) {
			final JvmField inferredField = this.associations.getJvmField(field);
			final Map<String, JvmField> inheritedFields = new TreeMap<>();
			Utils.populateInheritanceContext(
					inferredField.getDeclaringType(),
					null, null,
					inheritedFields,
					null, null,
					this.sarlActionSignatures);

			final JvmField inheritedField = inheritedFields.get(field.getName());
			if (inheritedField != null) {
				int nameIndex = 0;
				String newName = field.getName() + nameIndex;
				while (inheritedFields.containsKey(newName)) {
					++nameIndex;
					newName = field.getName() + nameIndex;
				}
				addIssue(MessageFormat.format(
						Messages.SARLValidator_42,
						field.getName(),
						inferredField.getDeclaringType().getQualifiedName(),
						inheritedField.getQualifiedName()),
						field,
						XTEND_FIELD__NAME,
						ValidationMessageAcceptor.INSIGNIFICANT_INDEX,
						VARIABLE_NAME_SHADOWING,
						newName);
			}
		}
	}
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);
            }
        }
    }
612694
public function getField($fieldName, $silent = false)
    {
        if (!array_key_exists($fieldName, $this->data) && $silent === false) {
            throw new ElasticSearchException(sprintf('The field %s was not present in data of document in %s/%s.', $fieldName, $this->type->getIndex()->getName(), $this->type->getName()), 1340274696);
        }

        return $this->data[$fieldName];
    }
308932
public static Field getDeclaredField(Class<?> clazz, String fieldName) throws SecurityException {
		if (null == clazz || StrUtil.isBlank(fieldName)) {
			return null;
		}
		try {
			return clazz.getDeclaredField(fieldName);
		} catch (NoSuchFieldException e) {
			// e.printStackTrace();
		}
		return null;
	}
1163260
@Nullable
  public final String getHiddenFieldName ()
  {
    final String sFieldName = getName ();
    if (StringHelper.hasNoText (sFieldName))
      return null;

    return HIDDEN_FIELD_PREFIX + sFieldName;
  }
440558
public <T> T getField(String fieldName, Class<T> clazz) {
        return DPathUtils.getValue(fieldData, fieldName, clazz);
    }
737104
public static <S, D extends S> void copyFields(final S src, D dest) throws IllegalArgumentException {
		Class<?> targetClass = src.getClass();

		do {
			Field[] fields = targetClass.getDeclaredFields();
			for (Field field : fields) {
				// Skip static fields:
				if (Modifier.isStatic(field.getModifiers())) {
					continue;
				}
				try {
					if ((!Modifier.isPublic(field.getModifiers())
					            || !Modifier.isPublic(field.getDeclaringClass().getModifiers())
					            || Modifier.isFinal(field.getModifiers())) && !field.isAccessible()) {
						field.setAccessible(true);
					}
					Object srcValue = field.get(src);
					field.set(dest, srcValue);
				}
				catch (IllegalAccessException ex) {
					throw new IllegalStateException(
					            "Shouldn't be illegal to access field '" + field.getName() + "': " + ex);
				}
			}
			targetClass = targetClass.getSuperclass();
		}
		while (targetClass != null && targetClass != Object.class);
	}
389261
public static String determineMutatorName(@Nonnull final String fieldName) {
		Check.notEmpty(fieldName, "fieldName");
		final Matcher m = PATTERN.matcher(fieldName);
		Check.stateIsTrue(m.find(), "passed field name '%s' is not applicable", fieldName);
		final String name = m.group();
		return METHOD_SET_PREFIX + name.substring(0, 1).toUpperCase() + name.substring(1);
	}