public static <T> T getFieldValue(Object target, String fieldName) {

    Preconditions.checkNotNull(target, "Target object is null");
    Preconditions.checkNotNull(fieldName, "Field name is null");

    Field field = null;
    Boolean prevAccessible = null;
    try {
      field = target.getClass().getDeclaredField(fieldName);
      prevAccessible = field.isAccessible();
      field.setAccessible(true);
      return (T) field.get(target);
    } catch (Exception ex) {
      throw new SamzaException(ex);
    } finally {
      if (field != null && prevAccessible != null) {
        field.setAccessible(prevAccessible);
      }
    }
  }
Get the value of the specified field from the target object
@param target target object
@param fieldName name of the field
@param <T> type of retrieved value
@return value of the field
samza-core/src/main/java/org/apache/samza/testUtils/TestUtils.java