Here you can find the source of findField(Class> cl, String fieldName)
public static Field findField(Class<?> cl, String fieldName) throws NoSuchFieldException
//package com.java2s; //License from project: Open Source License import java.lang.reflect.Field; import java.util.Objects; public class Main { public static Field findField(Class<?> cl, String fieldName) throws NoSuchFieldException { try {//from w w w. ja va2s . c o m return cl.getDeclaredField(fieldName); } catch (SecurityException sex) { return null; } catch (NoSuchFieldException e) { if (Objects.equals(cl, Object.class)) { throw e; } return findField(cl.getSuperclass(), fieldName); } } }