19

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

trunkc
  • 6,223
  • 4
  • 34
  • 49
  • 2
    Seems like closures are back: http://puredanger.com/tech/2009/11/18/closures-after-all/ – trunkc Nov 19 '09 at 10:48
  • 1
    oh Java, you used to be so cool, what happened? – maerics Jun 23 '11 at 17:20
  • I'm voting to close with a newer question since it will be more up to date with future features - possible duplicate of [Closure in Java 7](http://stackoverflow.com/questions/5443510/closure-in-java-7) – nawfal Jul 05 '14 at 07:35

6 Answers6

19

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
  • 69,183
  • 25
  • 122
  • 167
13

At Devoxx 2008, Mark Reinhold made it clear that closures will not be included in Java 7.


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


Belay that! Closures (lambda expressions) have been deferred until Java 8. Follow Project Lambda (JSR 335) for more information.

Bill the Lizard
  • 398,270
  • 210
  • 566
  • 880
erickson
  • 265,237
  • 58
  • 395
  • 493
7

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
  • 35,347
  • 40
  • 135
  • 226
3

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

billjamesdev
  • 14,554
  • 6
  • 53
  • 76
2

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

Joshua Fox
  • 18,704
  • 23
  • 87
  • 147
1

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
  • 13,548
  • 3
  • 28
  • 37