I have these two methods:
private static <T extends Throwable> void methodWithExceptionGeneric(final T t) throws T {
throw t;
}
private static void methodWithExceptionNonGeneric(final Throwable t) throws Throwable {
throw t;
}
When I call these methods like so:
methodWithExceptionGeneric(new IllegalArgumentException());
methodWithExceptionNonGeneric(new IllegalArgumentException()); // compile time error
I get a compile time error in the non generic method saying that I have an unhandled exception in my main method and I need to either declare a throws statement or catch the exception.
My question is: why is it only complaining about the non generic method? In my mind, the generic method is also throwing an exception so shouldn't that have to be handled too?