ExceptionUtils { public static void rethrowIfFatalError(Throwable t) { if (isJvmFatalError(t)) { throw (Error) t; } } private  ExceptionUtils(); static String stringifyException(final Throwable e); static boolean isJvmFatalError(Throwable t); static boolean isJvmFatalOrOutOfMemoryError(Throwable t); static void rethrowIfFatalError(Throwable t); static void rethrowIfFatalErrorOrOOM(Throwable t); static T firstOrSuppressed(T newException, @Nullable T previous); static void rethrow(Throwable t); static void rethrow(Throwable t, String parentMessage); static void rethrowException(Throwable t, String parentMessage); static void tryRethrowIOException(Throwable t); static void rethrowIOException(Throwable t); static Optional<Throwable> findThrowable(Throwable throwable, Class<?> searchType); static Optional<Throwable> findThrowableWithMessage(Throwable throwable, String searchMessage); static Throwable stripExecutionException(Throwable throwable); static Throwable stripCompletionException(Throwable throwable); static void tryDeserializeAndThrow(Throwable throwable, ClassLoader classLoader); static final String STRINGIFIED_NULL_EXCEPTION; }
@Test public void testRethrowFatalError() { try { ExceptionUtils.rethrowIfFatalError(new InternalError()); fail(); } catch (InternalError ignored) {} ExceptionUtils.rethrowIfFatalError(new NoClassDefFoundError()); }