Java lost exception -
suppose have following method (a simplified version):
void dosomething() { try { throw new exception("a"); } { throw new exception("b"); } } exception message "b" caught in caller method. basically, there way of knowing exception thrown in try block if block throws exception? suppose method dosomething() cannot modified.
section 14.20.2 of jls states:
if execution of try block completes abruptly because of throw of value v, ...
...
if block completes abruptly reason s, try statement completes abruptly reason s (and throw of value v discarded , forgotten).
java must discard original exception v ("complete abruptly") , whole try-finally block "completes abruptly" s (the finally exception, "b").
there no way retrieve original try block exception "a", corresponds v in jls.
Comments
Post a Comment