public static Field findFirstFieldByExactType(Class<?> clazz, Class<?> type) {
        Class<?> clz = clazz;
        do {
            for (Field field : clz.getDeclaredFields()) {
                if (field.getType() == type) {
                    field.setAccessible(true);
                    return field;
                }
            }
        } while ((clz = clz.getSuperclass()) != null);

        throw new NoSuchFieldError("Field of type " + type.getName() + " in class " + clazz.getName());
    }
Returns the first field of the given type in a class.
Might be useful for Proguard'ed classes to identify fields with unique types.

@param clazz The class which either declares or inherits the field.
@param type  The type of the field.
@return A reference to the first field of the given type.
@throws NoSuchFieldError In case no matching field was not found.
android/android_framework/base/src/main/java/util/XposedHelpers.java