Exception transparency - lone throws (no checked exceptions)

Paul Benedict pbenedict at apache.org
Thu Jun 17 16:37:00 PDT 2010


Remi, I am not proposing eliminating checked exceptions. My suggestion
is to allow the catching of checked exceptions without the compiler
having to prove that it is going to be thrown.

Example:
try {
// do nothing - nothing causes IOException here
} catch (IOException e) { }

That doesn't compile today. If we allowed it to compile, then checked
exceptions could be thrown out of closures without having to be
declared.

Paul

On Thu, Jun 17, 2010 at 5:58 PM, Rémi Forax <forax at univ-mlv.fr> wrote:
> Le 18/06/2010 00:47, Stephen Colebourne a écrit :
>> On 17 June 2010 22:52, Paul Benedict<pbenedict at apache.org>  wrote:
>>
>>> My only comment is on the the "catch throws" clause.
>>>
>> ...
>>
>>> 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.
>>>
>> This is perfectly possible and not backwards incompatible as far as I
>> can see (it simply makes code that wouldn't compile today start to
>> compile.)
>>
>
> It's possible but stupid.
> My students must be able to write webservers and without checked exceptions,
> it's hard to be done right. No one want a server that stop if a client
> shutdown the connection randomly.
>
> Checked exception is a good way to say You must do something here to deal
> with this uncommon case.
>
>> I would note that the catch side of checked exceptions is just as
>> important as the throws side to those that favour checked. Thats why I
>> chose the slightly less aggressive change with an additional keyword.
>> Were this proposal to be seriously considered, I'd expect that this
>> option would be very much on the table.
>>
>> Stephen
>>
>
> Rémi
>
>
>


More information about the lambda-dev mailing list