Check lambda support in IntelliJ IDEA 12 EAP build 122.202

Posted on by Maxim Mossienko

A new EAP build 122.202 of IntelliJ IDEA 12 has been released. The build contains improved JDK8 lambda inference and initial code insight features:

  • Anonymous class can be replaced with lambda inspection with a quick fix
  • Intention to replace lambda with anonymous class
  • Intention to insert inferred lambda parameter types

You can find the complete list of changes in the build. Download it or upgrade from within the IDE using the “Check for updates” feature.

Comments below can no longer be edited.

14 Responses to Check lambda support in IntelliJ IDEA 12 EAP build 122.202

  1. Dee says:

    August 24, 2012

    No way. Just No way! Niice 🙂

  2. jtonic says:

    August 24, 2012

    Great news.

    I’ve created a java project with latest JDK8 and I didn’t managed to run it:
    error: lambda expressions are not supported in -source 1.8
    (use -source 8 or higher to enable lambda expressions)
    I’ve tried to configure the Java Compiler additional options without success.

    Also Idea complains about creating a new TreeSet passing an inline lambda expression. If I extract the lambda expression in a separate local variable the error has gone.

    Code:
    public class LambdaTest {
    public static void main(String[] args) {
    Comparator c = (o1, o2)->{
    return o2.compareToIgnoreCase(o1);
    };
    Set strs = new TreeSet(c);
    strs.add(“Roxana”);
    strs.add(“Antonel”);
    strs.add(“Tutye”);
    strs.add(“Irina”);

    for (String str : strs) {
    System.out.println(“str = ” + str);
    }
    }
    }

    Regards

  3. Kon Soulianidis says:

    August 25, 2012

    Hi jtonic
    Make sure you get the correct build of JDK8 with lambdas enabled. http://jdk8.java.net/lambda/
    The regular one does not have it
    Best
    Kon

  4. Anna Kozlova says:

    August 27, 2012

    Hello,
    in order to get java build with lambda support you need to download it from http://jdk8.java.net/lambda/. It is not merged yet in the common repository, sorry not mentioned that.

  5. Denny says:

    August 27, 2012

    What’s the font in the picture?

  6. jtonic says:

    August 27, 2012

    Thank you Anna

    It works.

    Regarding the other issue, is it a JDK-1.8 issue or IDE one?

    Regards

  7. Anna Kozlova says:

    August 28, 2012

    Hi,
    actually this code
    {code}
    Set strs = new TreeSet();
    strs.add(“”);
    for (String str : strs) {}
    {code}
    should not compile (and is highlighted in IDEA) as ‘strs’ has raw type and cant be converted without cast to Set.
    On the other hand code
    {code}
    Set strs = new TreeSet((o1, o2) -> {
    return o2.compareToIgnoreCase(o1);
    });
    {code}
    compile but is highlighted in the IDE. Will investigate the problem. Thanks

  8. Anna Kozlova says:

    August 30, 2012

    The font is default (Tahoma 11)

  9. JohnPaul says:

    September 19, 2012

    public class MyClassTest extends TestCase {
    public void testFoo() {
    Comparable integerComparable = new Comparable() {
    @Override
    public int compareTo(Integer o) {
    return 0;
    }
    };
    }
    }

    does not offer an intention.

    $ java -version
    openjdk version “1.8.0-ea”
    OpenJDK Runtime Environment (build 1.8.0-ea-lambda-nightly-h1171-20120911-b56-b00)
    OpenJDK Client VM (build 24.0-b21, mixed mode)

    Idea @IU-122.337

    Any ideas?

  10. Anna Kozlova says:

    September 21, 2012

    Works here. Could you please check that your module has 1.8 language level. Otherwise IDEA would treat lambdas as unsupported feature, hence no intention would be suggested.
    Thanks

  11. Davide says:

    December 11, 2012

    is there already also support for map, filter and reduce operations on collections? Looks great anyway! Great job.

  12. Anna Kozlova says:

    December 12, 2012

    Davide, what support do you expect? Thanks

  13. David Turanski says:

    March 19, 2013

    Re. Collections support. Basic lambda examples are working for me. When I tried to do something simple like List.forEach {} it doesn’t compile. It appears it’s not part of the latest jdk 8 build yet, but I may be missing something. Does this work today?

  14. Anna Kozlova says:

    March 19, 2013

    To be sure you need to download java from http://jdk8.java.net/lambda/.

Subscribe

Subscribe for updates