public static Field getOptionalField ( Class < ? > clazz , String fieldName ) { try { Field field = clazz . getDeclaredField ( fieldName ) ; field . setAccessible ( true ) ; return field ; } catch ( NoSuchFieldException expectable ) { } catch ( SecurityException e ) { throw new BugError ( e ) ; } return null ; }
Get class field or null if not found . Try to get named class field and returns null if not found ; this method does not throw any exception .