We all know try-catch blocks inhibit certain compiler optimizations, as stated in the following:
"Placing code inside try-catch block inhibits certain optimizations that JVM implementations otherwise perform." Effective Java, Item 69 (Joshua Bloch)
Is it expensive to use try-catch blocks even if an exception is never thrown?
So, what about web applications? In web application, specifically in controllers, everything is - at some level - contained in a try-catch block. We know that because, in case of an unhandled exception, our app won't crash but returns a Server Error 500. Can we say that any code running within a web controller is implicitly checked for exceptions, with the consequences that we mentioned (inhibited optimization)?
UPDATE. I try to narrow down the question, which is purely theoretical by the way. The original assumption is: JVMs cannot apply certain optimizations to code inside a try-catch block. So:
Does the lack of those optimizations apply also to method calls?
Or in other words:
Can JVMs optimize code inside a method called from a try-catch block? Or does a try-catch block prevent optimization on any piece of code - even method calls down the stacktrace - executed within it?