Try catch after turning off assertions, what happens with them?

Sincere question, Why do people say catching errors are code smell?

If you open the most basic library, lets say the ArrayList Iterator implementation, there would be an exception there.

If you open the DatabaseReference class from Google's Firebase at least 10% of the code is String validation exception checks.

I mean I get you, exceptions ARE a significant performance hit.... but ONLY at the moment of stack Trace copying.

BUT the try{} is immediate, I know this because I've had discussions about this in the past with reputable sources.

No one that builds a library, relies uniquely on its documentation, EVERYONE insists (and with good reason) on putting checks on each step of the process to prevent undesirable results.

As for me ... I kind of agree with you.. I particularly don't like Exceptions... hence my assertion usage.... and hence the reason for this question....

Having said this (the "try is immediate" part a few sentences above...) if the try is really free... and the asserts disappear, then the execution will be unaffected... but it still bothers me that the try{} is there at all...

/r/javahelp Thread Parent