More as an experiment, I decided to enable the following breakpoint in the Eclipse debugger: Throwable [Include Subclasses]: caught and uncaught
. I then let my code (which is running "fine" as far as I know) run under the debugger, and was surprised to see dozens of exceptions being thrown and caught (previously unknown to me) by standard J2SE library code when my code was running normally for all I know.
For example, here are just some of the Java framework functions I found throwing exceptions: URLClassLoader.findClass
, FileDirContext.lookup
, and WebappClassLoader.findClassInternal
.
Is this considered normal behavior for a Java application? Is this something I should look into? My code seems to be running fine as far as I know.
Though it is bad to design your code in this way (exceptions are slow, and should be used for exceptional circumstances), Bhesh Gurung's comment is the right way to think about this. Follow the specification of the code you are relying on, and don't worry about the implementation.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With