Proposal: Automatic Resource Management

Roel Spilker r.spilker at gmail.com
Mon Mar 9 17:17:31 PDT 2009


Josh,

Another benefit of the AutoClosable interface is that static code analyzers,
such as findbugs and Eclipse, could find AutoClosable instances that are
never closed if they are used outside ARM blocks and don't escape out of the
method, or if they are accessed after close has been called.

SWT has an abstract class Resource that is the base class of all
OS-dependent system resources, like Color, Cursor, Font, Image etc. The
contract states you have to call dispose on them manually to release the
resource to the OS again. It would be trivial for the SWT developers to
retrofit the Resource class to implement the AutoClosable interface so the
application programmer can benefit from the ARM blocks.

Roel



More information about the coin-dev mailing list