Exception transparency - lone throws (no checked exceptions)
Paul Benedict
pbenedict at apache.org
Thu Jun 17 14:52:28 PDT 2010
Stephen,
I think your implementation and explanation was thought provoking and
clever. I like what you did.
My only comment is on the the "catch throws" clause. It allows checked
exceptions to be handled in an unchecked manner, but I would rather
solve the root problem. Today, the compiler forces you to catch
declared checked exceptions, and will not allow you to catch
undeclared checked exceptions. For example, if I try to catch
IOException but the try/catch body has nothing that provably throws
IOExceptions, I cannot compile. It's the latter that is the stumbling
block here.
Why doesn't Java relax its exception catching rules so that it's legal
to catch undeclared checked exceptions? So the compiler cannot
definitively prove the exception will be thrown, so what? It should be
backwards compatible since it is illegal today, and it takes away this
"catch throws" clause that is a bit hackish -- albeit necessary.
Thoughts?
Paul
More information about the lambda-dev
mailing list