static void writeField(final Class targetClass, final Object targetInstance,
      final String fieldName, final Object value) {
    try {
      Field field = targetClass.getDeclaredField(fieldName);
      field.setAccessible(true);
      field.set(targetInstance, value);
    } catch (IllegalAccessException | NoSuchFieldException e) {
      throw new Error(e);
    }
  }
Provides support for serialization of private fields by reflection.
geode-junit/src/main/java/org/apache/geode/test/junit/rules/serializable/FieldSerializationUtils.java