code: public static FontMetrics getFontMetrics(JComponent c, Graphics g) {
          if (getFontMetricsMethod != null) {
              try {
                  return (FontMetrics) getFontMetricsMethod.invoke(null, new Object[]{c, g});
              } catch (IllegalArgumentException e) {
                  // Use the fallback
              } catch (IllegalAccessException e) {
                  // Use the fallback
              } catch (InvocationTargetException e) {
                  // Use the fallback
              }
          }
          return c.getFontMetrics(g.getFont());
      }
docs: Returns the FontMetrics for the current Font of the passed in Graphics. This method is used
  when a Graphics is available, typically when painting. If a Graphics is not available the
  JComponent method of the same name should be used.
  <p>
  Callers should pass in a non-null JComponent, the exception to this is if a JComponent is not
  readily available at the time of painting.
  <p>
  This does not necessarily return the FontMetrics from the Graphics.
  
  @param c JComponent requesting FontMetrics, may be null
  @param g Graphics Graphics
  @return the FontMetrics