zhong.j.yu at gmail.com
Wed Aug 25 09:54:32 PDT 2010
On Wed, Aug 25, 2010 at 5:58 AM, David Holmes <David.Holmes at oracle.com> wrote:
> Gernot Neppert said the following on 08/24/10 22:29:
>>> Well I disagree that the exception in the try block is necessarily more
>>> important than the one in the finally block.
>> It might not be more important, but it might be the only one that you
>> can spot by looking at the code:
> I was referring to try-finally, not try-with.
>> try(Reader reader = new FileReader("contents.txt"))
>> char buf = new char;
>> int read;
>> while(0 < (read = reader.read(buf)))
>> // Do something
>> Wouldn't you want the above block to re-throw exceptions from the
>> constructor or from 'read', rather than from an 'invisible' exception
> This really is an argument against hiding the code in the first place.
> When you read the above you have to implicitly "see" the hidden close
> that might also throw an exception.
Was there any proposal to explicitly close(), with a cleaner syntax
than the traditional try-finally?
> Regardless of which exception is thrown you will want/need to follow the
> chain to get the full picture of what has gone wrong.
> David Holmes
>> (See also my other post suggesting that the compiler might be more
>> helpful in pointing at 'hidden' exception sources)
More information about the coin-dev