Why can a
throw statement inside a
finally block override a thrown exception or a
return statement executed in the associated
First off, we know that, by definition of the
finally statement (Section 14.19 of the JLS), the
finally block is executed no matter what happens in the
Next, also by definition, both the
return (Section 14.16) and
(Section 14.17) statements complete abruptly.
finallyblock (Section 14.19.2) causes the try/catch/finally statement to complete abruptly.
Therefore, executing a
throw in the
finally clause abruptly
finally clause which, in turn, abruptly completes the
try statement which therefore has the effect of
masking/overriding any previous
statement executed in the associated try/catch blocks.
So, take a look at your try/catch/finally statements and check to see that you're actually handling exceptions and returns the way that you expected.