Suppose I have a class named BugException which extends from RuntimeException
And BugException has a copy constructor which takes a Throwable.
This code compiles and typechecks:
Throwable e = ...;
if (e instanceof BugException) {
throw new BugException(e);
}
Why is it that:
Throwable e = ...;
if (e instanceof BugException) {
throw e;
}
Does not compile and gives the error message: unhandled exception. java.lang.Throwable. ?
Why is this unnecessary wrapping necessary to satisfy the typechecker?