private static Object withAccessibleField(Object owner, String fieldName,
      BiFunction<Object, Field, Object> operation) {
    Field field = getField(owner, fieldName);
    boolean accessible = field.isAccessible();
    try {
      field.setAccessible(true);
      return operation.apply(owner, field);
    } finally {
      field.setAccessible(accessible);
    }
  }
Makes a field temporarily accessible and applies the operation to it.
build-tools/geode-testing-isolation/src/main/java/org/apache/geode/gradle/testing/process/Reflection.java