Skip to main content

JDK7: lose the "try"

No replies
Joined: 2003-07-23

Don't know if this is to late for JDK7, but this is something I was wondering about a lot lately: is the try keyword really required?

I understand "try" is needed to inform the compiler that it needs to add the code for handling exceptions to the next block, but why isn't it possible to simply add catch and finally constructs to every block? I.o.w.: lose the try keyword and assume every block has one. The compiler can certainly optimize a not used try construct away, if at the end it turns out there is no catch or finally.