Proposal: Automatic Resource Management (original) (raw)
Joshua Bloch jjb at google.com
Sat Mar 7 20:45:14 PST 2009
- Previous message: Proposal: Automatic Resource Management
- Next message: Proposal: Automatic Resource Management
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
Neal,
On Sat, Mar 7, 2009 at 11:45 AM, Neal Gafter <neal at gafter.com> wrote:
On Sat, Mar 7, 2009 at 10:40 AM, Joshua Bloch <jjb at google.com> wrote: > Neal, > Sorry, I should have defined my terms. I define a "true resource" as an > object that can only used once, and then must be disposed of, never to be > used again.
That's not the usual definition, (see <http://en.wikipedia.org/wiki/Resource(computerscience)>),
The words "true resource" don't occur in this article. And Wikipedia is far from authoritative.
This definition would appear to include classes and interfaces such as
java.sql.Statement (close) java.nio.channels.FileLock (release) org.ietf.jgss.GSSCredential (dispose) java.awt.image.VolatileImage (flush) I think one of these use cases is currently supported by the proposal.
Nothing is currently supported: types must be retrofitted to mark them as resources. So the question is, which of these types can be retrofitted? On a quick reading, it would appear that only GSSCredential presents a problem: it's an interface (not a class) and it's disposal method is named "flush." Luckily, it's not commonly used (only 3k google hits vs. 300k for java.sql.Statement). The goal here is simply to hit the common cases. I believe the proposed feature will do that, even if we elect to implement the simple (interface-based) version.
Josh
- Previous message: Proposal: Automatic Resource Management
- Next message: Proposal: Automatic Resource Management
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]