code: @SuppressWarnings("unchecked")
      public static <T> T getInternalState(Object object, String fieldName, Class<?> where) {
          if (object == null || fieldName == null || fieldName.equals("") || fieldName.startsWith(" ")) {
              throw new IllegalArgumentException("object, field name, and \"where\" must not be empty or null.");
          }
  
          Field field = null;
          try {
              field = where.getDeclaredField(fieldName);
              field.setAccessible(true);
              return (T) field.get(object);
          } catch (NoSuchFieldException e) {
              throw new FieldNotFoundException("Field '" + fieldName + "' was not found in class " + where.getName()
                                                       + ".");
          } catch (Exception e) {
              throw new RuntimeException("Internal error: Failed to get field in method getInternalState.", e);
          }
      }
docs: Get the value of a field using reflection. Use this method when you need
  to specify in which class the field is declared. This might be useful
  when you have mocked the instance you are trying to access. Use this
  method to avoid casting.
  
  @param <T>       the expected type of the field
  @param object    the object to modify
  @param fieldName the name of the field
  @param where     which class the field is defined
  @return the internal state