Henry Wong wrote:I am actually somewhat impress that the compiler caught this -- it seems pretty dumb in many cases.
Most compiler errors like are mandated by the JLS, not left to the discretion of the implementor. They didn't want programs to compile on some systems and not others. So it isn't really a matter of how smart or dumb the compiler is, but what depth of flow analysis was chosen by the JLS authors as standard. In this case, the rules are given in
JLS 11.2.2. I think it makes sense that they
had to put in special rules for handling try/catch, since otherwise you could never "handle" an exception as far as the compiler is concerned - and once they put in rules for try/catch, it would have been extremely foolish not to also consider how finally could affect the outcome.