when in eclipse i use a method which throws an exception, it usually complains if it is not surrounded by a try/catch or if the exception is not thrown again. But for some exceptions (e.g. Integer.parseInt(string)) eclipse won’t complain.
How do i set eclipse to complain for all not handled exceptions??
Thanks!
The simple answer is that you can’t.
The longer answer is:
Checked versus unchecked exceptions is a fundamental part of the Java language.
It is not the role of the Eclipse compiler to give compilation errors or warnings for valid and perfectly acceptable Java.
You wouldn’t want it to either, considering that the majority of statements could (in theory) throw or propagate exceptions such as
NullPointerException,ArrayIndexOutOfBoundsException,OutOfMemoryError, and so on.Yes, there are one or two “mistakes” … such as
NumberFormatExceptionbeing an unchecked exception … but a better way to deal with that would be (for example) to run PMD with some custom rules to pick up exceptions that “ought to be” treated as checked.