code: private static <T extends Annotation> @Nullable T safeGetAnnotation(
        Field f, Class<T> annotationClass) {
      @Nullable T annotation;
      try {
        @SuppressWarnings("cast") // cast is redundant (except for type annotations)
        @Nullable T cast = f.getAnnotation((Class<@NonNull T>) annotationClass);
        annotation = cast;
      } catch (Exception e) {
        // Can get
        //   java.lang.ArrayStoreException: sun.reflect.annotation.TypeNotPresentExceptionProxy
        // when an annotation is not present at run time (example: @NonNull)
        System.out.printf(
            "Exception in call to f.getAnnotation(%s)%n  for f=%s%n  %s%nClasspath =%n",
            annotationClass, f, e.getMessage());
        // e.printStackTrace();
        printClassPath();
        annotation = null;
      }
  
      return annotation;
    }
docs: Like {@link Field#getAnnotation}, but returns null (and prints a warning) rather than throwing
  an exception.
  
  @param <T> the type of the annotation to query for and return if present
  @param f the Field that may contain the annotation
  @param annotationClass the Class object corresponding to the annotation type, or null
  @return this element's annotation for the specified annotation type if present on this element,
  else null