/** * Retrieves a Field object for a given field on the specified class, having set it accessible. * * @param cls the Class on which the field is expected to be defined * @param fieldName the name of the field of interest * @throws NoSuchFieldException in case of any error retriving information about the field */ private static Field getField(Class cls, String fieldName) throws NoSuchFieldException { try { Field field = cls.getDeclaredField(fieldName); field.setAccessible(true); return field; } catch (NoSuchFieldException nsfe) { NoSuchFieldException e = new NoSuchFieldException(getMessage("classloaderutil.errorGettingField", fieldName)); e.initCause(nsfe); throw e; } }