DZone
Thanks for visiting DZone today,
Edit Profile
  • Manage Email Subscriptions
  • How to Post to DZone
  • Article Submission Guidelines
Sign Out View Profile
  • Post an Article
  • Manage My Drafts
Over 2 million developers have joined DZone.
Log In / Join
Refcards Trend Reports Events Over 2 million developers have joined DZone. Join Today! Thanks for visiting DZone today,
Edit Profile Manage Email Subscriptions Moderation Admin Console How to Post to DZone Article Submission Guidelines
View Profile
Sign Out
Refcards
Trend Reports
Events
Zones
Culture and Methodologies Agile Career Development Methodologies Team Management
Data Engineering AI/ML Big Data Data Databases IoT
Software Design and Architecture Cloud Architecture Containers Integration Microservices Performance Security
Coding Frameworks Java JavaScript Languages Tools
Testing, Deployment, and Maintenance Deployment DevOps and CI/CD Maintenance Monitoring and Observability Testing, Tools, and Frameworks
Culture and Methodologies
Agile Career Development Methodologies Team Management
Data Engineering
AI/ML Big Data Data Databases IoT
Software Design and Architecture
Cloud Architecture Containers Integration Microservices Performance Security
Coding
Frameworks Java JavaScript Languages Tools
Testing, Deployment, and Maintenance
Deployment DevOps and CI/CD Maintenance Monitoring and Observability Testing, Tools, and Frameworks
  1. DZone
  2. Coding
  3. Java
  4. What's in Store for Project Lambda in Java 8?

What's in Store for Project Lambda in Java 8?

Mohamed Sanaulla user avatar by
Mohamed Sanaulla
CORE ·
Jul. 19, 12 · Interview
Like (0)
Save
Tweet
Share
5.58K Views

Join the DZone community and get the full member experience.

Join For Free

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.

Functional Interfaces

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:

  • What are functional interfaces and functional Descriptors?

Lambda expressions

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.

Java (programming language)

Published at DZone with permission of Mohamed Sanaulla, DZone MVB. See the original article here.

Opinions expressed by DZone contributors are their own.

Popular on DZone

  • The Future of Cloud Engineering Evolves
  • Secrets Management
  • Streamlining Your Workflow With the Jenkins HTTP Request Plugin: A Guide to Replacing CURL in Scripts
  • Memory Debugging: A Deep Level of Insight

Comments

Partner Resources

X

ABOUT US

  • About DZone
  • Send feedback
  • Careers
  • Sitemap

ADVERTISE

  • Advertise with DZone

CONTRIBUTE ON DZONE

  • Article Submission Guidelines
  • Become a Contributor
  • Visit the Writers' Zone

LEGAL

  • Terms of Service
  • Privacy Policy

CONTACT US

  • 600 Park Offices Drive
  • Suite 300
  • Durham, NC 27709
  • support@dzone.com
  • +1 (919) 678-0300

Let's be friends: