I'm trying to come up with some simple rules to remember regarding exceptions in overridden methods in Java 8.
I've seen some posts explaining this in a kind of long way or not so clear to me.
Assume when saying "Checked exception" it means the method has throws <checked-exception> in its signature etc.
- Checked exceptions can stay the same or be narrowed, even to not throwing at all.
- Unchecked exceptions (runtime exceptions) have no rules (can be narrowed or widened or neither).
To keep the statement simple assume that narrowing "not throwing at all" is "not throwing at all" and widening "not throwing at all" is to throw any exception (corresponding to checked/unchecked case)
Summarizing this to:
- checked
>=overriding-checked - unchecked, overriding-unchecked are independent
Is this all (and correct?) or are there some cases missing?