ARM API Support
forax at univ-mlv.fr
Thu Jun 24 10:54:59 PDT 2010
Le 24/06/2010 16:57, Joe Darcy a écrit :
> Rémi Forax wrote:
>> Le 24/06/2010 02:08, Joe Darcy a écrit :
>>> The initial API changes to support the Project Coin feature automatic
>>> resource management (ARM) blocks have been pushed into JDK 7  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:
>>> * 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
>>> 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,
>>> top-level interface to mark participation in ARM is in package
>>> 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.
>>>  http://hg.openjdk.java.net/jdk7/tl/jdk/rev/c4d60bcce958
>> There is a bug in printStackTrace(PrintStreamOrWriter)
>> Set<Throwable> dejaVu = new HashSet<Throwable>();
>> should be:
>> Set<Throwable> dejaVu = Collections.newSetFromMap(
>> new IdentityHashMap<Throwable,Boolean>());
>> The current code doesn't work as expected if an exception overrides
> Hi Rémi,
> Thanks for catching this bug. I'll correct that when I next edit the
> file -- I plan to change the addSuppressedException method to throw an
> exception if the exception tries to suppress itself.
I also think you can get ride of the PrintStream/PrintWriter adapters.
Both implements Appendable, and you can synchronize on that appendable.
println(s) can be replaced by append(s).append(lineSeparator),
the lineSeparator is available with this code:
lineSeparator = java.security.AccessController.doPrivileged(
Perhaps it can be stored in a public static final variable.
More information about the coin-dev