Platinum Partner
java,fcm,bgga,devoxx,jdk 7

Update on Closures Coming to Java 7

It was announced yesterday that closures would be added to JDK 7.  Mark Reinhold made the announcement at the Devoxx conference.  Before today, Sun could not reach a consensus on the inclusion of closures in JDK 7.  Three proposals for closures were submitted to Sun over the last few years.  With the JDK 7 schedule extended to September 2010, Reinhold seems to think that now is the time to bring closures to Java.

A few more details about the closures announcement for Java 7 surfaced today.  According to Stephen Colebourne's blog, Mark Reinhold's Devoxx announcement indicated that "JDK 7 closures will not have control-invocation statements as a goal, nor will it have non-local returns.  He [Reinhold] also indicated that access to non-final variables was unlikely.  Beyond this, there wasn't much detail on semantics, nor do I believe that there has been much consideration of semantics yet."

Here's a strawman syntax for closures that Mark Reinhold wrote on his plane ride to the conference:

  // function expressions
#(int i, String s) {
System.println.out(s);
return i + s.length();
}

// function expressions
#(int i, String s) (i + s.length())

// function types
#int(int, String)



The syntax resembles the FCM closure proposal, but Reinhold made it clear that he was using FCM as an example and not endorsing it.  Joseph Darcy from Sun said the closures would be "Smaller than BGGA."  A few weeks before the conference, Neal Gafter, a co-author of the BGGA closure proposal, wrote a simple specification for closures in Java.

{{ tag }}, {{tag}},

{{ parent.title || parent.header.title}}

{{ parent.tldr }}

{{ parent.urlSource.name }}
{{ parent.authors[0].realName || parent.author}}

{{ parent.authors[0].tagline || parent.tagline }}

{{ parent.views }} ViewsClicks
Tweet

{{parent.nComments}}