harmony-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Nathan Beyer <ndbe...@apache.org>
Subject Re: SneakyThrow!
Date Wed, 18 Nov 2009 03:16:37 GMT
On Tue, Nov 17, 2009 at 10:33 AM, Jesse Wilson <jessewilson@google.com> wrote:
> On Tue, Nov 17, 2009 at 7:56 AM, Tim Ellison <t.p.ellison@gmail.com> wrote:
>> The difference I see, by just staring at the code and without running
>> it, is that if the 'thrown' Throwable that was caught earlier is not one
>> of the tested types (IOException | RuntimeException | Error) then the
>> original code throws an AssertionError, whereas sneaky will re-throw the
>> raised type.
>> Not sure why the original has AssertionError...
> Yeah, the repeated "throw" statements in that code obscured my intentions.
> "throw new AssertionError()" is idiomatic for lines of code that should

This idiom is still not well understood, which is why i generally put
a comment above any AssertionError throw "// should never happen".
That may just be my preventative habit for avoiding questions and
confusing looks.

I also suspect that the concept of 'assert' in any programming
language is not well understood.


> never ever be executed. In this case, IOException, RuntimeException and
> Error were the only things that could have been thrown by the try blocks.

View raw message