Android Class Field Find findFieldRecursiveImpl(Class clazz, String fieldName)

Here you can find the source of findFieldRecursiveImpl(Class clazz, String fieldName)

Description

find Field Recursive Impl

Declaration

private static Field findFieldRecursiveImpl(Class<?> clazz,
            String fieldName) throws NoSuchFieldException 

Method Source Code

//package com.java2s;

import java.lang.reflect.Field;

public class Main {
    private static Field findFieldRecursiveImpl(Class<?> clazz,
            String fieldName) throws NoSuchFieldException {
        try {/*from w w  w. java 2  s .co m*/
            return clazz.getDeclaredField(fieldName);
        } catch (NoSuchFieldException e) {
            while (true) {
                clazz = clazz.getSuperclass();
                if (clazz == null || clazz.equals(Object.class))
                    break;

                try {
                    return clazz.getDeclaredField(fieldName);
                } catch (NoSuchFieldException ignored) {
                }
            }
            throw e;
        }
    }
}

Related

  1. findField(Class clazz, String fieldName)
  2. findFirstFieldByExactType(Class clazz, Class type)
  3. getAdditionalStaticField(Class clazz, String key)
  4. getFields(Class cs)