Automatic Resource Management, V.2
Joshua Bloch
jjb at google.com
Mon Apr 20 13:26:45 PDT 2009
Paul,
On Mon, Apr 20, 2009 at 12:59 PM, Paul Martin <paul.martin at gmail.com> wrote:
> Hi,
>
> >> > *5. Some failures of the **close** method can be safely ignored (e.g.,
> >
> > Yes; you could do that. Of course you'd have to write a separate
> decorator
> > for every such type. But it's worth mentioning that in the FAQ, and I
> will
> > do so.
>
> Just to clarify, I think that "HideAutoCloseableExceptionsAdapter"
> should work with any AutoCloseable (as long as the decorated object is
> declared before the try), so you could use that to address Neal
> Gafter's point 5: "*5. Some failures of the **close** method can be
> safely ignored (e.g.,closing a file that was open for read). Does the
> construct provide for this?". Simply using a standard decorator would
> seem to be a reasonable solution (since ignoring close exceptions
> would normally be done on a usage case-by-case basis). Giving the
> adapter a better name, such as "IgnoreCloseExceptionAdapter" might
> help, or even a static factory method such as AutoCloseable
> autocloseQuietly(AutoCloseable delegate).
Yes, you are correct. I didn't read your example carefully. You don't need
a separate adapter for each type if you're willing to declare the instance
outside the scope of the block.
As for the "AutoCloseableItertor" stuff, I think it can wait for a
subsequent release. I see it as scope-creep that distracts from the central
goals of the proposal and reduces the likelihood that it will be
successfully delivered into Java 7.
Regards,
Josh
More information about the coin-dev
mailing list