/** * Returns the Method that can be used to return the size of a stack, or null if that method * cannot be found (it is only to be found in fairly recent JDKs). Tries to test method {@link * sun.misc.JavaLangAccess#getStackTraceDepth(Throwable)} getStackTraceDepth} prior to return it * (might fail some JDKs). * * <p>See <a href="https://github.com/google/guava/issues/2887">Throwables#lazyStackTrace throws * UnsupportedOperationException</a>. */ @GwtIncompatible // java.lang.reflect private static @Nullable Method getSizeMethod() { try { Method getStackTraceDepth = getJlaMethod("getStackTraceDepth", Throwable.class); if (getStackTraceDepth == null) { return null; } getStackTraceDepth.invoke(getJLA(), new Throwable()); return getStackTraceDepth; } catch (UnsupportedOperationException | IllegalAccessException | InvocationTargetException e) { return null; } }
/** * Returns the Method that can be used to return the size of a stack, or null if that method * cannot be found (it is only to be found in fairly recent JDKs). Tries to test method {@link * sun.misc.JavaLangAccess#getStackTraceDepth(Throwable)} getStackTraceDepth} prior to return it * (might fail some JDKs). * * <p>See <a href="https://github.com/google/guava/issues/2887">Throwables#lazyStackTrace throws * UnsupportedOperationException</a>. */ @GwtIncompatible // java.lang.reflect @NullableDecl private static Method getSizeMethod() { try { Method getStackTraceDepth = getJlaMethod("getStackTraceDepth", Throwable.class); if (getStackTraceDepth == null) { return null; } getStackTraceDepth.invoke(getJLA(), new Throwable()); return getStackTraceDepth; } catch (UnsupportedOperationException | IllegalAccessException | InvocationTargetException e) { return null; } }
/** * Returns the Method that can be used to return the size of a stack, or null if that method * cannot be found (it is only to be found in fairly recent JDKs). Tries to test method {@link * sun.misc.JavaLangAccess#getStackTraceDepth(Throwable)} getStackTraceDepth} prior to return it * (might fail some JDKs). * * <p>See <a href="https://github.com/google/guava/issues/2887">Throwables#lazyStackTrace throws * UnsupportedOperationException</a>. */ @GwtIncompatible // java.lang.reflect @NullableDecl private static Method getSizeMethod() { try { Method getStackTraceDepth = getJlaMethod("getStackTraceDepth", Throwable.class); if (getStackTraceDepth == null) { return null; } getStackTraceDepth.invoke(getJLA(), new Throwable()); return getStackTraceDepth; } catch (UnsupportedOperationException | IllegalAccessException | InvocationTargetException e) { return null; } }
/** * Returns the Method that can be used to return the size of a stack, or null if that method * cannot be found (it is only to be found in fairly recent JDKs). Tries to test method {@link * sun.misc.JavaLangAccess#getStackTraceDepth(Throwable)} getStackTraceDepth} prior to return it * (might fail some JDKs). * * <p>See <a href="https://github.com/google/guava/issues/2887">Throwables#lazyStackTrace throws * UnsupportedOperationException</a>. */ @GwtIncompatible // java.lang.reflect private static @Nullable Method getSizeMethod() { try { Method getStackTraceDepth = getJlaMethod("getStackTraceDepth", Throwable.class); if (getStackTraceDepth == null) { return null; } getStackTraceDepth.invoke(getJLA(), new Throwable()); return getStackTraceDepth; } catch (UnsupportedOperationException | IllegalAccessException | InvocationTargetException e) { return null; } }
/** * Returns the Method that can be used to return the size of a stack, or null if that method * cannot be found (it is only to be found in fairly recent JDKs). Tries to test method {@link * sun.misc.JavaLangAccess#getStackTraceDepth(Throwable)} getStackTraceDepth} prior to return it * (might fail some JDKs). * * <p>See <a href="https://github.com/google/guava/issues/2887">Throwables#lazyStackTrace throws * UnsupportedOperationException</a>. */ @GwtIncompatible // java.lang.reflect @NullableDecl private static Method getSizeMethod() { try { Method getStackTraceDepth = getJlaMethod("getStackTraceDepth", Throwable.class); if (getStackTraceDepth == null) { return null; } getStackTraceDepth.invoke(getJLA(), new Throwable()); return getStackTraceDepth; } catch (UnsupportedOperationException | IllegalAccessException | InvocationTargetException e) { return null; } }