lambda finder available!
Thomas Jung
thomas.andreas.jung at googlemail.com
Fri Nov 12 22:09:24 PST 2010
Hi Maurizio,
nice feature. Could the message also contain the lambda expression?
I've no idea about the compiler internals. Can you generate java code
from the AST at this stage?
Hopefully IDEs will support batch conversions when lambda expressions
are in Java.
Thomas
On 12 November 2010 18:55, Maurizio Cimadamore
<maurizio.cimadamore at oracle.com> wrote:
> Hi,
> 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:
>
> Test.java:2: 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.
>
> Maurizio
>
>
>
More information about the lambda-dev
mailing list