harmony-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Tim Ellison <t.p.elli...@gmail.com>
Subject Re: SneakyThrow!
Date Tue, 17 Nov 2009 16:53:44 GMT
On 17/Nov/2009 16:33, Jesse Wilson 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
> never ever be executed. In this case, IOException, RuntimeException and
> Error were the only things that could have been thrown by the try blocks.

I see, you fooled me in your original note with:

> Consider the full body of BufferedWriter.close(), in particular the
> last 10 lines.

Now I've gone back and looked, they were never the real last 10 lines of
the close() method.  More a case of, rather than code it like this ... I
did it like this ..., right?


View raw message