Here you can find the source of findFieldIncludeSuperclass(String fieldName, Class> clazz)
protected static Field findFieldIncludeSuperclass(String fieldName, Class<?> clazz)
//package com.java2s; /*//from w w w. ja v a 2s . c om * Copyright 1999-2004 Alibaba.com All right reserved. This software is the confidential and proprietary information of * Alibaba.com ("Confidential Information"). You shall not disclose such Confidential Information and shall use it only * in accordance with the terms of the license agreement you entered into with Alibaba.com. */ import java.lang.reflect.Field; public class Main { protected static Field findFieldIncludeSuperclass(String fieldName, Class<?> clazz) { Field retValue = null; try { retValue = clazz.getDeclaredField(fieldName); } catch (NoSuchFieldException e) { clazz = clazz.getSuperclass(); if (clazz != null) { retValue = findFieldIncludeSuperclass(fieldName, clazz); } } return retValue; } }