Facilitating the Spread of Knowledge and Innovation in Professional Software Development

Write for InfoQ


Choose your language

InfoQ Homepage News Mark Mahieu Creates CICE Closure Prototype

Mark Mahieu Creates CICE Closure Prototype

This item in japanese

One of the hottest topics in Java in recent years has been around adding full closure support to the Java language. Given the complexity that closures could introduce however, it is difficult to judge their full impact without being able to experiment with prototypes for the various proposals.

Now, joining Neal Gafter's BGGA proposal prototype, Mark Mahieu has begun putting together a prototype implementation of the CICE/ARM proposal written by Bob Lee, Doug Lea, and Josh Bloch. Concise Instance Creation Expressions (CICE) simply provide a more compact syntax for instantiating instances of an inner class with a single abstract method such as Runnable, Callable, or Comparator. Automatic Resource Management (ARM) blocks support one of the main use cases for closures; the scoping of resource use within a block such that when you exit the lexical scope of the block you automatically call the close method on the resource.

Mahieu's initial implementations are limited in scope. For CICE, just expressions, public local variables and implicitly final local variables are implemented; public locals and type inference are not. The ARM block implementation supports only the do() { } form of ARM block and relies on as a starting point. As noted by Mahieu and in the ARM specification itself, using Closeable is problematic since many existing types - java.sql.Connection, Statement, ResultSet and so on - could not be made to implement it in view of the fact that they throw other unchecked exceptions.

The prototype is already helping to drive out some details in the proposals with a newer build of the ARM implementation changing the default semantics of the do() { } form for checked exceptions.

With Stephen Colebourne working on a prototype for FCM we should be able to start getting much more of a feel for which aspects of the proposals work or don't over the next year.

Rate this Article