ARM API Support

Joe Darcy joe.darcy at oracle.com
Tue Jul 13 19:47:26 PDT 2010


PS Additional platform classes have been retrofitted for use with ARM 
(http://hg.openjdk.java.net/jdk7/tl/jdk/rev/425960cef714):

Retrofit as AutoCloseable:
    java.beans.XMLEncoder
    java.beans.XMLDecoder
    java.io.ObjectInput
    java.io.ObjectOutput
    javax.sound.sampled.Line
    javax.sound.midi.Receiver
    javax.sound.midi.Transmitter
    javax.sound.midi.MidiDevice
 
Retrofit as Closeable:
    java.util.Scanner

Candidates for retrofitting were identified by running an annotation 
processor over the JDK sources; for details see:

"Project Coin: Bringing it to a Close(able)"
http://blogs.sun.com/darcy/entry/project_coin_bring_close

-Joe

Joe Darcy wrote:
> Greetings
>
> The initial API changes to support the Project Coin feature automatic 
> resource management (ARM) blocks have been pushed into JDK 7 [1] and 
> will appear in subsequent builds. The corresponding compiler changes 
> to support the actual language feature remain in progress.
>
> The initial API work to support ARM was divided into two pieces, 
> essential API support and retrofitting platform classes. The essential 
> support includes:
>
> * A new interface java.lang.AutoCloseable which defines a single method
>  void close() throws Exception
>
> * A new enum constant in the language model:
>  javax.lang.model.element.ElementKind.RESOURCE_VARIABLE
>
> * Methods on java.lang.Throwable to add and retrieve information about 
> suppressed exceptions, including printing out suppressed exceptions in 
> stack traces.
>
> The retrofitting includes:
>
> * Having java.io.Closeable extend java.lang.AutoCloseable. (From a 
> typing perspective, a subtype of AutoCloseable can be declared to 
> throw fewer exceptions than the supertype. Therefore is is fine for 
> the close method in AutoCloseable to throw Exception and the close 
> method in Closeable to throw the more specific IOException. It would 
> even be fine for the close method in a subtype of AutoCloseable to be 
> declared to throw no exceptions at all.)
>
> * Adding a close method to java.nio.channels.FileLock and having 
> FileLock implement AutoCloseable.
>
> * Adding Closeable as an interface implemented by 
> javax.imageio.stream.ImageInputStream.
>
> Other platform classes may be retrofitted to implement AutoCloseable 
> or 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.sql.* nor java.awt.Graphics were 
> retrofitted for ARM.
>
> -Joe
>
> [1] http://hg.openjdk.java.net/jdk7/tl/jdk/rev/c4d60bcce958
>    http://hg.openjdk.java.net/jdk7/tl/langtools/rev/be5cafeb318d
>




More information about the coin-dev mailing list