tags:

views:

1127

answers:

7

Does anybody know, if closures will be in Java 7?

+19  A: 

It is unknown until the Java SE 7 JSR is created (presumably by Danny Coward) and an expert group is formed and the contents selected.

My Java 7 page is a good collection of links about Java 7 in general and has links to all of the closures proposals and blog entries:

http://tech.puredanger.com/java7#closures

And I maintain a Java 7 link blog where you can find links on closures and other stuff at:

http://java7.tumblr.com

And you might find my Java 7 Predictions blog post to be interesting as well if you want my opinions: http://tech.puredanger.com/2008/08/02/java7-prediction-update/

UPDATE: Mark Reinhold stated at Devoxx in Dec. 08 that closures will NOT be included in Java 7 due to a lack of consensus on how to implement.

Alex Miller
Great links, thanks for your work!
bwalliser
+6  A: 

There are currently several competing proposals, BGGA, CICE, among others. Unfortunately, a heated debate remains over the best approach. As a result it is unlikely at this point that closures will make it into Java 7, due to the conservative nature of the acceptance process.

The key problem here is that it can be very difficult to add features to a pre-existing language, without inadvertently introducing significant complexity. This was the experience with Generics in Java 1.5, and many are concerned that it would be compounded with the introduction of closures.

My advice is that if you really want to have access to modern language features like closures, but wish to stay within the Java ecosysteym, you should take a look at Scala.

sanity
Groovy also supports closures.
Rui Vieira
+3  A: 

Groovy is the best Java alternative I've seen that includes features of dynamic languages including closures, run-time class extension, etc. While Ruby has a slight design advantage imho, I'd have to say the fact that Groovy compiles into Java byte-code and interacts with Java without ANY interface code is a huge plus that can't be ignored.

http://groovy.codehaus.org

Bill James
+2  A: 

Apparently Closures will not be in Java 7. See this and this.

Joshua Fox
A: 

Closure won't definitively be present in Java 7, but if you are looking for a lighter solution to have closure in java right now check out how they have been implemented in the lambdaj library:

http://code.google.com/p/lambdaj/wiki/Closures

Mario Fusco
+1  A: 

I have just read a report that says that closures will be in Java 7, can anyone confirm or deny this?

Thanks

John V.
@John W. ask a new question instead of answering one. Also see the previous answer on this same thread: http://stackoverflow.com/questions/116865/whats-the-current-state-of-closures-in-java/533063#533063 : *Apparently Closures will not be in Java 7.*
OscarRyz
Yes, it was communicated at Devoxx'09... Read this: http://java.dzone.com/news/closures-coming-java-7
Fredrik
+4  A: 

Closures will be included in Java 7. Mark Reinhold announced this reversal at Devoxx 2009.

erickson