> I'm not sure what you refer to exactly,

The various links from

  https://docs.oracle.com/javase/7/docs/api/java/io/IOException.html

or even

  https://docs.oracle.com/javase/7/docs/api/java/lang/Exception.html


> but I noted already that not all
> references are equal, especially if you quote design decisions that date
> back from the early Java days (when every textbook touted checked
> exceptions as _the_ solution to robust programming).
>

So IllegalArgumentException is not from the early Java days?



> ...
> Ask yourself how the programmer will handle the exception ? If the
> programmer
> can’t do better than e.printStackTrace() or throw new AssertionError(),
> then, an
> unchecked exception is called for.
>

And I guess that's the point - the programmer can do better.

There should be a difference of action when the code knows the archive is
broken in contrast there being a problem with the code reading it (for
whatever reason).

One is "sorry, this is an invalid archive" while the other is "something
went wrong reading the archive - printStackTrace". If that distinction is
not important to you - so be it. To me that's a big difference.

The "sorry, this is an invalid archive" is what makes the situation
for me "recoverable".
For me "recoverable" does not mean running the same code with the same
input twice and expecting a different result.

If you continue to read your link to "Effective Java", the use of
"Optional" is suggested as the proper alternative to a checked exception.
And to be honest I'd be all for that - on a new code base. But you'd still
need figure out the "canCompute" to make the distinction between the two
states.

Reply via email to