lambda finder available!

Maurizio Cimadamore maurizio.cimadamore at
Fri Nov 12 09:55:19 PST 2010

I'd like to spend few time in order to discuss a feature that I pushed 
while back and that probably went unnoticed (I just realized that the 
commit message didn't contain anything too specific about that :-) ).

The idea is to find all potential anonymous inner class creation 
expressions that can be potentially replaced by a lambda expression. In 
order to turn this 'lambda finder' feature on, you need to pass the 
compiler the hidden flag '-XDidentifyLambdaCandidate=true'.

This is an example of how the flag works; assume that you have the 
following code:

class Test {
Runnable r = new Runnable() { void run() { System.out.println("Hello!"); 
} };

if you compile the above program with the hidden flag, javac will emit 
the following note: Note: This anonymous inner class creation can be turned 
into a lambda expression.
Runnable r = new Runnable() { public void run() { 
System.out.println("Hello!"); } };

This means that this feature can be helpful (I hope) in order to 
refactor existing code base to use lambda expressions.


More information about the lambda-dev mailing list