public static Field getDeclaredField ( Class < ? > clazz , String fieldName , boolean recursively ) { try { return clazz . getDeclaredField ( fieldName ) ; } catch ( NoSuchFieldException e ) { Class < ? > superClass = clazz . getSuperclass ( ) ; if ( superClass != null && recursively ) { return getDeclaredField ( superClass , fieldName , true ) ; } } catch ( SecurityException e ) { log . error ( "{}" , e . getMessage ( ) , e ) ; } return null ; }
obtain field If recursively is true obtain fields from all class hierarchy