public StackTraceElement getStackTraceElement(Throwable throwable, int n) {
    try {
      return (StackTraceElement) getElementMethod.invoke(javaLangAccess, throwable, n);
    } catch (InvocationTargetException e) {
      // The only case we should expect to see here normally is a wrapped IndexOutOfBoundsException.
      if (e.getCause() instanceof RuntimeException) {
        throw (RuntimeException) e.getCause();
      } else if (e.getCause() instanceof Error) {
        throw (Error) e.getCause();
      }
      // This should not be possible because the getStackTraceElement() method does not declare
      // any checked exceptions (though APIs may change over time).
      throw new RuntimeException(e.getCause());
    } catch (IllegalAccessException e) {
      // This should never happen because the method has been successfully invoked once already.
      throw new AssertionError(e);
    }
  }
public StackTraceElement getStackTraceElement ( Throwable throwable , int n ) { try { return ( StackTraceElement ) getElementMethod . invoke ( javaLangAccess , throwable , n ) ; } catch ( InvocationTargetException e ) { if ( e . getCause ( ) instanceof RuntimeException ) { throw ( RuntimeException ) e . getCause ( ) ; } else if ( e . getCause ( ) instanceof Error ) { throw ( Error ) e . getCause ( ) ; } throw new RuntimeException ( e . getCause ( ) ) ; } catch ( IllegalAccessException e ) { throw new AssertionError ( e ) ; } }
Mimics a direct call to {@code getStackTraceElement()} on the JavaLangAccess interface without
requiring the Java runtime to directly reference the method (which may not exist on some
JVMs).