Does not perform {@link PrivilegedAction} unless necessary.

@param javaClass
@param fieldName
@return a field from the class
@throws NoSuchMethodException
20
static Field lookupField(Class<?> javaClass, String fieldName) throws NoSuchFieldException {
        if (System.getSecurityManager() != null) {
            try {
                return AccessController.doPrivileged(new FieldLookupAction(javaClass, fieldName));
            } catch (PrivilegedActionException e) {
                if (e.getCause() instanceof NoSuchFieldException) {
                    throw (NoSuchFieldException) e.getCause();
                }
                throw new WeldException(e.getCause());
            }
        } else {
            return FieldLookupAction.lookupField(javaClass, fieldName);
        }
    }
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;
  }
29698
public static Class<?> getPropertyClass(Class<?> beanClass, String field) {
        try {
            return INSTANCE.findPropertyClass(beanClass, field);
        } catch (NoSuchMethodException | IllegalAccessException | InvocationTargetException e) {
            throw handleReflectionException(beanClass, field, e);
        }
    }
1246726
private static Field getDeclaredField(Object object, String fieldName) throws NoSuchFieldException {
        Assert.notNull(object);
        return getDeclaredField(object.getClass(), fieldName);
    }
418042
public static void setFieldValue(final Class<?> source, final Object target, final String fieldName, final Object value) throws NoSuchFieldException
    {
        try
        {
            AccessController.doPrivileged(new PrivilegedExceptionAction<Void>()
            {
                @Override
                public Void run() throws Exception
                {
                    Field field = source.getDeclaredField(fieldName);
                    if(!field.isAccessible())
                    {
                        field.setAccessible(true);
                    }
                    field.set(target, value);
                    return null;
                }
            });
        }
        // Unwrap
        catch (final PrivilegedActionException pae)
        {
            final Throwable t = pae.getCause();
            // Rethrow
            if (t instanceof NoSuchFieldException)
            {
                throw (NoSuchFieldException) t;
            }
            else
            {
                // No other checked Exception thrown by Class.getConstructor
                try
                {
                    throw (RuntimeException) t;
                }
                // Just in case we've really messed up
                catch (final ClassCastException cce)
                {
                    throw new RuntimeException("Obtained unchecked Exception; this code should never be reached", t);
                }
            }
        }
    }
681920
static Method lookupMethod(Class<?> javaClass, String methodName, Class<?>... parameterTypes) throws NoSuchMethodException {
        if (System.getSecurityManager() != null) {
            try {
                return AccessController.doPrivileged(new MethodLookupAction(javaClass, methodName, parameterTypes));
            } catch (PrivilegedActionException e) {
                if (e.getCause() instanceof NoSuchMethodException) {
                    throw (NoSuchMethodException) e.getCause();
                }
                throw new WeldException(e.getCause());
            }
        } else {
            return MethodLookupAction.lookupMethod(javaClass, methodName, parameterTypes);
        }
    }
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;
    }
188125
@Nonnull
  public JSDefinedClass removeField (@Nonnull final JSFieldVar aField)
  {
    ValueEnforcer.notNull (aField, "Field");

    if (m_aFields.remove (aField.name ()) != aField)
      throw new IllegalArgumentException ("Failed to remove field '" +
                                          aField.name () +
                                          "' from " +
                                          m_aFields.keySet ());
    return this;
  }
868550
public static Field findField(String className, String fieldName) throws ClassNotFoundException {
        JavaClass jclass = Repository.lookupClass(className);

        while (jclass != null) {
            Field[] fieldList = jclass.getFields();
            for (Field field : fieldList) {
                if (field.getName().equals(fieldName)) {
                    return field;
                }
            }

            jclass = jclass.getSuperClass();
        }

        return null;
    }
920089
public function isAllowedField($modelClass, $fieldName, $privilege = null)
    {
        return $this->isAllowed($this->fieldResourceGenerator($modelClass, $fieldName), $privilege);
    }
1252135
public static Field findClassField(Class<?> beanClass, String fieldName) {
		Class<?> currentClass = beanClass;
		while (currentClass != null && currentClass != Object.class) {
			for (Field field : currentClass.getDeclaredFields()) {
				if (field.isSynthetic()) {
					continue;
				}

				if (field.getName().equals(fieldName)) {
					return field;
				}
			}
			currentClass = currentClass.getSuperclass();
		}

		return null;
	}
133041
private static JaxInfo[] buildFields(Class<?> clazz, String defaultNS) throws SecurityException, NoSuchFieldException, ClassNotFoundException {
		ArrayList<JaxInfo> fields = null; // allow for lazy instantiation, because many structures won't have XmlType
		Class<?> cls = clazz;
		// Build up Method names from JAXB Annotations
		XmlType xt;
		while((xt = cls.getAnnotation(XmlType.class))!=null) {
			if(fields==null)fields = new ArrayList<JaxInfo>();
			for(String field : xt.propOrder()) {
				if("".equals(field)) break; // odd bug.  "" returned when no fields exist, rather than empty array
				Field rf = cls.getDeclaredField(field);
				Class<?> ft = rf.getType();
				
				boolean required = false;
				boolean nillable = false;
				String xmlName = field;
				String namespace = defaultNS;
				
				XmlElement xe = rf.getAnnotation(XmlElement.class);
				if(xe!=null) {
					xmlName=xe.name();
					required = xe.required();
					nillable = false;
					if(DEFAULT.equals(xmlName)) {
						xmlName = field;
					}
					namespace = xe.namespace();
					if(DEFAULT.equals(namespace)) {
						namespace = defaultNS;
					}
				}
				// If object is a List, then it is possible multiple, per XML/JAXB evaluation
				if(ft.isAssignableFrom(List.class)) {
					Type t = rf.getGenericType();
					String classname = t.toString();
					int start = classname.indexOf('<');
					int end = classname.indexOf('>');
					Class<?> genClass = Class.forName(classname.substring(start+1, end));
					xe = genClass.getAnnotation(XmlElement.class);
					if(xe!=null && !DEFAULT.equals(xe.namespace())) {
						namespace = xe.namespace();
					}
					// add recursed recursed member, marked as array
					fields.add(new JaxInfo(xmlName,namespace,genClass,buildFields(genClass,namespace), genClass.equals(String.class),true,required,nillable));
				} else {
					boolean isString = ft.equals(String.class) || ft.equals(XMLGregorianCalendar.class);
					// add recursed member
					fields.add(new JaxInfo(xmlName,namespace,ft,buildFields(ft,namespace),isString,false,required,nillable));
				}
			}
			cls = cls.getSuperclass();
		};
		if(fields!=null) {
			JaxInfo[] rv = new JaxInfo[fields.size()];
			fields.toArray(rv);
			return rv;
		} else {
			return null;
		}
	}
715903
protected String getFieldKey(Field field, Class<? extends ActionBean> actionBeanClass) {
        // Use key attribute if it is defined.
        String sessionKey = ((Session)field.getAnnotation(Session.class)).key();
        if (sessionKey != null && !"".equals(sessionKey)) {
            return sessionKey;
        }
        else {
            // Use default key since no custom key is defined.
            return actionBeanClass + "#" + field.getName();
        }
    }
185880
@FFDCIgnore(PrivilegedActionException.class)
    private Object getJNDIServiceObjectInstance(final String className, final String bindingName, final Hashtable<?, ?> envmt) throws Exception {
        try {
            return AccessController.doPrivileged(new PrivilegedExceptionAction<Object>() {
                @Override
                public Object run() throws Exception {
                    return getJNDIServiceObjectInstancePrivileged(className, bindingName, envmt);
                }
            });
        } catch (PrivilegedActionException paex) {
            Throwable cause = paex.getCause();
            if (cause instanceof Exception) {
                throw (Exception) cause;
            }
            throw new Error(cause);
        }
    }
879367
private Field findFieldInClass(Class klass, String fieldName) throws NoSuchFieldException {
        try {
            return klass.getDeclaredField(fieldName);
        } catch (NoSuchFieldException e) {
            Class superclass = klass.getSuperclass();
            if (superclass != null) {
                return findFieldInClass(superclass, fieldName);
            }
            throw new NoSuchFieldException();
        }
    }
568036
public static Field changeFieldAccess(Class<?> clazz, String fieldName)
	{
		return changeFieldAccess(clazz, fieldName, fieldName, false);
	}
241657
public static Object getFieldValue(Object object, String fieldName) throws NoSuchFieldException {
        Field field = getDeclaredField(object, fieldName);
        if (!field.isAccessible()) {
            field.setAccessible(true);
        }

        Object result = null;
        try {
            result = field.get(object);
        } catch (IllegalAccessException e) {
            logger.error("不可能抛出的异常{}", e.getMessage());
        }
        return result;
    }