Proposal: Automatic Resource Management
Joshua Bloch
jjb at google.com
Wed Mar 4 23:15:30 PST 2009
Xavi,
Thanks very much for the feedback!
Josh
On Wed, Mar 4, 2009 at 9:49 PM, Xavi Miró <xmirog at gmail.com> wrote:
> I like the simplicity of Josh' solution, the rule of throwing the most
> important exception (the first) and silent the others, using an
> interface whose method close simply throws Exception...For the Java
> source code I've been writing for the last 10 years it would fit 100%, I
> can't remember any "corner case" where it wouldn't fit well, but of
> course if we can apply this solution to more use cases without losing
> much simplicity, that would be perfect.
>
> For me, using a modifier like finally would also be acceptable.
>
> I would love to have this ARM proposal in Java 7!
>
> Xavi
>
> Stephen Colebourne wrote:
> > > interface Disposable {
> > > void close() throws Exception;
> > > }
> > > interface Destroyable {
> > > void dispose() throws Exception;
> > > }
> > > interface Kloseable {
> > > void destroy() throws Exception;
> > > }
> >
> > Er, no. If its to be an interface it needs to be just one.
> >
> > A single interface - Disposable defining close() covers most use cases,
> > and API writers would adapt in the future.
> >
> >
> >> public finally void release() { ... }
> >>
> >
> > I think this works well, and opens up more options. Are there any
> > specific grammer objections?
> >
> > It would be possible to add a marker interface Finally which enforces
> > the presence of the finally modifier, but that seems to have little
> > obvious benefit, and be a bit magical.
> >
> > Stephen
> >
> >
> >
>
>
>
More information about the coin-dev
mailing list