throw
statements inside finally
blocks.
While occasionally intended, such throw
statements can hide exceptions thrown from the try
and
catch
blocks, thereby complicating the debugging process.
Example:
class Fascinating {
void doTask(Task t) {
try {
t.activity();
} finally {
if (!t.finish()) {
throw new IllegalStateException();
}
}
}
}
Use the Warn everywhere declared exceptions may be thrown option to warn on method calls to methods that declare exceptions as well.