@Test public void testThrowUnknownException() { assertFalse(ExceptionUtil.throwException("unknown.exception.class", "test")); }
public static boolean throwException(String className, String message) { try { Class<Throwable> throwableClass = forName(className); Constructor<Throwable> constructor = throwableClass.getConstructor(String.class); Throwable throwable = constructor.newInstance(message); throwException(throwable); return true; } catch (ClassNotFoundException e) { return false; } catch (NoSuchMethodException e) { return false; } catch (InvocationTargetException e) { return false; } catch (InstantiationException e) { return false; } catch (IllegalAccessException e) { return false; } }
ExceptionUtil { public static boolean throwException(String className, String message) { try { Class<Throwable> throwableClass = forName(className); Constructor<Throwable> constructor = throwableClass.getConstructor(String.class); Throwable throwable = constructor.newInstance(message); throwException(throwable); return true; } catch (ClassNotFoundException e) { return false; } catch (NoSuchMethodException e) { return false; } catch (InvocationTargetException e) { return false; } catch (InstantiationException e) { return false; } catch (IllegalAccessException e) { return false; } } }
ExceptionUtil { public static boolean throwException(String className, String message) { try { Class<Throwable> throwableClass = forName(className); Constructor<Throwable> constructor = throwableClass.getConstructor(String.class); Throwable throwable = constructor.newInstance(message); throwException(throwable); return true; } catch (ClassNotFoundException e) { return false; } catch (NoSuchMethodException e) { return false; } catch (InvocationTargetException e) { return false; } catch (InstantiationException e) { return false; } catch (IllegalAccessException e) { return false; } } protected  ExceptionUtil(); }
ExceptionUtil { public static boolean throwException(String className, String message) { try { Class<Throwable> throwableClass = forName(className); Constructor<Throwable> constructor = throwableClass.getConstructor(String.class); Throwable throwable = constructor.newInstance(message); throwException(throwable); return true; } catch (ClassNotFoundException e) { return false; } catch (NoSuchMethodException e) { return false; } catch (InvocationTargetException e) { return false; } catch (InstantiationException e) { return false; } catch (IllegalAccessException e) { return false; } } protected  ExceptionUtil(); static boolean throwException(String className, String message); static void throwException(Throwable e); static boolean addSuppressed(Throwable e, Throwable suppressed); static String generateMessage(String s, StackTraceElement[] closeStackTrace); static void throwTargetException(InvocationTargetException ite); static RuntimeException processException(Throwable e); }
ExceptionUtil { public static boolean throwException(String className, String message) { try { Class<Throwable> throwableClass = forName(className); Constructor<Throwable> constructor = throwableClass.getConstructor(String.class); Throwable throwable = constructor.newInstance(message); throwException(throwable); return true; } catch (ClassNotFoundException e) { return false; } catch (NoSuchMethodException e) { return false; } catch (InvocationTargetException e) { return false; } catch (InstantiationException e) { return false; } catch (IllegalAccessException e) { return false; } } protected  ExceptionUtil(); static boolean throwException(String className, String message); static void throwException(Throwable e); static boolean addSuppressed(Throwable e, Throwable suppressed); static String generateMessage(String s, StackTraceElement[] closeStackTrace); static void throwTargetException(InvocationTargetException ite); static RuntimeException processException(Throwable e);  }