Automatic Resource Management, V.2
jjb at google.com
Mon Apr 20 07:34:21 PDT 2009
On Mon, Apr 20, 2009 at 4:00 AM, Bruce Chapman <brucechapman at paradise.net.nz
>> final *T**ype* #localVar = *Expression*;
> The type in the generated declaration above could simply be AutoClosable
> rather than the specific type of the expression?
Unfortunately it could not: if it were, the ARM statement could throw the
wrong exception type. If Expression is of a subclass of AutoCloseable whose
close method throws a particular set of exceptions (or none at all), it's
important that the enclosing statement behaves as if #localVar.close()
throws exactly the same set of exceptions. You are correct that it's not
possible to express this in declaration in the source language, but I
believe the compiler will have no trouble doing it. I will confirm this.
This issue does merit a note in the spec, and I will write one shortly.
More information about the coin-dev