Proposal: Automatic Resource Management (original) (raw)
Mark Mahieu markmahieu at googlemail.com
Tue Mar 3 19:39:16 PST 2009
- Previous message: Proposal: Automatic Resource Management
- Next message: Proposal: Automatic Resource Management
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
So would APIs be encouraged to define more specific Resource
interfaces that narrow the thrown exception types ...
interface SQLResource extends Resource { void dispose() throws SQLException { } }
interface SWTResource extends Resource { void dispose() throws SWTException { } }
etc?
Mark
On 4 Mar 2009, at 03:16, Bob Lee wrote:
On Tue, Mar 3, 2009 at 6:47 PM, Neal Gafter <neal at gafter.com> wrote:
I guess I assumed you were aware why people complain about Closeable.close() throwing IOException. Josh alluded to this when he said that Disposable won't be terribly useful as a parameter type. When you pass it somewhere, the receiver must assume that the close() method throws any Exception, and that forces the receiver to write code to handle the whole Exception hierarchy. I think it's likely that programmers would want to pass a Disposable around so that the receiver can put a region of code under control of the resource (i.e. dispose it when the receiver arrives at some particular point of completion). I'm afraid this would just be trading one set of pain points for another.
I think the new Disposable interface will work out very nicely (we could also name it Resource instead, but that can be left for the EG). Bob
- Previous message: Proposal: Automatic Resource Management
- Next message: Proposal: Automatic Resource Management
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]