The Oracle documentation on the multi-catch feature added to Java 7 states that the exception parameter in the catch
clause is implicitly final
.
My question is: what's the point of such restriction? Because i can't seem to find a single crucial improvement it brings. Marking a reference object as final
only protects the reference itself from being modified, not the object it references, and one is never prohibited to create another reference and modify it in whatever way they want.
A somewhat relevant question on SO discusses the reasons why modifying the exception reference in a catch
clause is not the wisest thing to do, but it relates to any use of the catch
clause, not just the multi-catch form of it. So why does Java make an, ahem, exception for the multi-catch and treat it in a special way?