Proposal: Automatic Resource Management
jjb at google.com
Sat Feb 28 12:33:03 PST 2009
On Sat, Feb 28, 2009 at 11:27 AM, Neal Gafter <neal at gafter.com> wrote:
> On Sat, Feb 28, 2009 at 11:08 AM, Joshua Bloch <jjb at google.com> wrote:
> >> Particularly concerning to me is
> >> the fact that this translation would sometimes silently swallow
> >> exceptions indicating serious program failures
> > Unless I am missing something, the construct only "silently swallows"
> > exceptions when they are intentionally suppressed in favor of prior
> > exceptions, which typically indicate more serious problems.
> The language construct as you specified it has no way to determine
> which exception is more serious. For example, a VM failure, such as
> an out-of-memory condition on the close(), is more serious than a
> closed connection on a particular write.
Please take a closer look at the desugaring! Like all VM
failures, OutOfMemoryError is not a subtype of Exception, so it will never be
suppressed by the automatic resource management statement. This is by
design. While the specified suppression behavior may not be perfect, it
does a far better job than most programmers do when left to cope with the
More information about the coin-dev