Project Coin: ARM API
By Darcy-Oracle on Jun 23, 2010
The initial API changes to support the Project Coin feature automatic resource management (ARM) blocks have been pushed into JDK 7 (
jdk) and will appear in subsequent builds.
The corresponding compiler changes to support the actual language feature remain in progress.
A new interface
java.lang.AutoCloseablewhich defines a single method
void close() throws Exception
A new enum constant in the language model:
java.lang.Throwableto add and retrieve information about suppressed exceptions, including printing out suppressed exceptions in stack traces.
The retrofitting includes:
java.lang.AutoCloseable. (From a typing perspective, a subtype of
AutoCloseablecan be declared to throw fewer exceptions than the supertype. Therefore is is fine for the
Closeableto throw the more specific
IOException. It would even be fine for the
closemethod in a subtype of
AutoCloseableto be declared to throw no exceptions at all.)
Closeableas an interface implemented by
Other platform classes may be retrofitted to implement
Closable in future builds.
Compared to the API support in earlier versions of the ARM proposal, the top-level interface to mark participation in ARM is in package
java.lang rather than its own package and, after consultation with the JDBC and graphics teams, neither
java.awt.Graphics were retrofitted for ARM.