Trying Out Lambda Expressions in the Eclipse IDE

A new article, now up on otn/java, by Deepak Vohra, titled “Trying Out Lambda Expressions in the Eclipse IDE,” demonstrates how to take advantage of lambda expressions in Java SE 8 using the Eclipse IDE and virtual extension methods.

Vohra begins with the basics:
“Lambda expressions, also called closures, are a short-form replacement for anonymous classes. Lambda expressions simplify the use of interfaces that declare a single abstract method, which are also called functional interfaces. In Java SE 7, a single method interface can be implemented with one of the following options.
* Create a class that implements the interface.
* Create an anonymous class.”

Vohra explains that while lambda expressions can be used to implement a functional interface without creating a class or an anonymous class, they can be used only with interfaces that declare a single method.

Benefits of lambda expressions include:
* Concise syntax
* Method references and constructor references
* Reduced runtime overhead compared to anonymous classes

Vohra gets under the hood to explain the basics of lambda syntax, along with the nature of functional interfaces and target types, offering copious examples. All in all, the article offers a first-rate primer on how to make use of lambda expressions and virtual extension methods using the Eclipse IDE.

Check out the story here.


I can't get it to work, is there any way to get some help with this?

Posted by guest on September 01, 2013 at 08:52 AM PDT #

Hi Janice,
By taking Deepak Vohra's article as reference, I have written a similar blog on
There I have mentioned a point saying "Its' Runtime overhead is less than Anonymous class" under "Why To Use It?" heading. But unfortunately I don't know how to proove it.
Theoritically it looks right but I need to show that to my viewers. Can you please help me on that?

Posted by Chandra Sekhar Nayak on September 03, 2013 at 09:36 PM PDT #

Hello Guest and Chandra, I'll get in touch with the writer, Deepak Vohra, re: your questions/requests and he'll probably comment here or try to reach you directly. Thanks for your interest.


Posted by Jan Heiss on September 04, 2013 at 01:44 PM PDT #

I can't get it to work, is there any way to get some help with this?

What is the error or the issue you are having? The most common omission is that the JDK 8 JRE has not been installed and Java Compiler Compliance has not been set to JDK 1.8.

Posted by Deepak Vohra on September 04, 2013 at 01:57 PM PDT #

Anonymous classes differ from the lambda expressions in that anonymous classes involve creating a new class type and instantiating a new object of the class type, while lambda expressions don't. At runtime anonymous classes involve the following:
1. Class loading.
2. Memory allocation and creating a new object.
3. Invocation of a method of the object.

Lambda expressions involve type inferencing and functional interface conversion, which is done at compile time. Lambda expressions at runtime involve the following using invokedynamic byte code:
1.Creating the synthetic type, which is inferred at compile time, for a lambda object.
2. Creating a lambda object.
3. Invoking the lambda object method.

invokedynamic is a new feature in JVM 7; invokedynamic is a new bytecode instruction and runtime support
library that allows a lower level of access to class loading and linking operations within
the JVM with a higher level of performance. Method invocation with invokedynamic provides increased runtime performance. A constant method in a constant pool is defined using invokedynamic bytecode, thus, not requiring creating a new object for each lambda expression method invocation.

For the measurement of invokedynamic performance use some library such as the following.

Posted by Deepak Vohra on September 04, 2013 at 03:25 PM PDT #

see this:

Posted by guest on September 05, 2013 at 09:57 PM PDT #

Post a Comment:
  • HTML Syntax: NOT allowed

Insider News from the Java Team at Oracle!

javeone logo


« April 2014