Java Reflection Field Find findField(final Class clazz, final String name)

Here you can find the source of findField(final Class clazz, final String name)

Description

find Field

License

Apache License

Declaration

private static Field findField(final Class<?> clazz, final String name) throws ReflectiveOperationException 

Method Source Code

//package com.java2s;
//License from project: Apache License 

import java.lang.reflect.Field;

public class Main {
    private static Field findField(final Class<?> clazz, final String name) throws ReflectiveOperationException {
        Class<?> theClazz = clazz;
        while (theClazz != null) {
            try {
                return theClazz.getDeclaredField(name);
            } catch (NoSuchFieldException e) {
                theClazz = theClazz.getSuperclass();
            }/*from   w w  w  .  java  2  s.co  m*/
        }

        throw new NoSuchFieldException(name);
    }
}

Related

  1. findField(Class targetClass, String fieldName)
  2. findField(Class type, Class annotationClass)
  3. findField(Class type, String fieldName)
  4. findField(final Class aClass, final String fieldName)
  5. findField(final Class clazz, final String name)
  6. findField(final Class clazz, final String name, final Class type)
  7. findField(final Class cls, final String fieldName)
  8. findField(final Class currentClass, final String fieldName)
  9. findField(final Class declaringClass, final String fieldName)