There are lot of things happening in the Project Lambda branch of JDK 8 and these are quite significant for Java programmers. I know lot of Anti-Java people would criticize these changes claiming them to be too late. But for loads of the Java developers out there its a welcome change. At this point of time the specs for Project Lambda part of JSR 335 are evolving, but I think lot of basic ground work done is kind of frozen. For those who want to try out the Project Lambda you should download the binaries from here.
The important concepts as part of Project Lambda are:
- Virtual Extension Methods
- Functional Interfaces
- Lambda Expressions
- API Enhancements to Collections library
- Method and Constructor references
I have tried my hand at some of these concepts and barely managed to scratch the surface. I have blogged about few of the concepts with examples:
Virtual Extension Methods
We all know how limiting the interfaces can be, without being able to have method implementations in interfaces we at times tend to copy over the common implementations across different classes or create a adapter class with the common implementations. This is one side of it, but the other side is that it gives no scope for API enhancements without breaking the existing code. You cannot get away with adding a new method in the Interface without breaking millions of lines of code using your API. A similar kind of issue was being faced by the collections library which started to show their age. So a new feature in the language without the existing APIs being able to support them is hardly of any value. With an idea to enhance the existing collections API the concept of Virtual Extension Methods was introduced. In the early draft version 2 these have been referred to as default methods.
The blog posts which I wrote for this were:
- Introduction to Virtual Extension Methods in Java 8 .
- Resolution of invocation of Virtual Extension Methods.
- Use of Virtual Extension Methods in Java 8 API.
The Single Abstract Method (SAM) classes are now being referred to as Functional Interfaces. And these functional Interfaces can be replaced by lambda expression. The compiler then identifies the context in which this lambda expression is being used and then correspondingly converts the lambda expression into the SAM class. There’s another concept associated with this which is: “Functional Descriptor”. A functional descriptor of the Functional interface is the method type of the single abstract method of the interface.
Blog post related to this:
This is the main feature of this JSR. The idea of this is to support closures in Java. All those Anonymous Inner classes can be replaced by the Lambda expressions. The Collections API has also been enhanced with new APIs which accepts these lambda expressions.
The blog posts which I wrote for this are:
- A sneak peak at the Lambda expression in Java 8.
- Enhanced Collections API in Java 8 supports Lambda expressions.
- Using Lambda expressions of Java 8 in JavaFX event handlers.
With the above blog posts I have barely scratched the surface. There’s lot to be learnt in this and a sound knowledge in Generics can help to a really great extent. Lot of them would say that the specs are in Draft and things can change, but I believe its always good to know what was there before and what changed and the reason for change. And its always good to keep yourself one step ahead of others so that when it is released you are in quite a good shape to welcome the changes!
Please feel free to correct me if I have made any mistakes in my understanding of the various features. There’s always an opportunity to learn from mistakes.
No related posts.
Connect to us …
- May 2013 (8)
- April 2013 (6)
- March 2013 (6)
- January 2013 (5)
- November 2012 (2)
- September 2012 (1)
- July 2012 (5)
- June 2012 (1)
- May 2012 (4)
- April 2012 (7)
- March 2012 (2)
- February 2012 (4)
- December 2011 (2)
- November 2011 (4)
- October 2011 (2)
- September 2011 (1)
- August 2011 (1)
- July 2011 (1)
- June 2011 (1)
- May 2011 (1)
- April 2011 (1)
- February 2011 (4)
- December 2010 (3)
- November 2010 (2)
- September 2010 (2)
- August 2010 (3)
- May 2010 (2)
- March 2010 (6)
- December 2009 (1)
- November 2009 (3)
- July 2009 (6)
- June 2009 (3)
- May 2009 (1)
- April 2009 (6)
- March 2009 (1)
- January 2009 (1)
- December 2008 (8)
- November 2008 (5)
- October 2008 (6)
- September 2008 (4)
- August 2008 (8)
- July 2008 (19)
- June 2008 (29)
- May 2008 (27)
- April 2008 (11)
- March 2008 (8)
- February 2008 (22)
- January 2008 (3)
Send To ReadmillSend to Readmill
- How to create ADF TreeTable programmatically?
- Book review: The Object-Oriented Thought Process
- How to show links in ADF Messages
- Runtime Polymorphism in Java
- Understanding RowKey values in ADF TreeTable
- Train Wreck Pattern – A much improved implementation in Java 8
- Converting a List into comma separated value string in Java
- A simple application of Lambda Expressions in Java 8
- Template Method Pattern- Using Lambda Expressions, Default Methods
- First look at Learning Play! Framework 2
Some of the links contained within this site have my referral id, which provides me with a small commission for each sale. Thank you for your support.