Check lambda support in IntelliJ IDEA 12 EAP build 122.202

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.

This entry was posted in EAP Releases and tagged , . Bookmark the permalink.

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

  1. Dee says:

    No way. Just No way! Niice :-)

  2. jtonic says:

    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:

    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:

    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:

    What’s the font in the picture?

  6. jtonic says:

    Thank you Anna

    It works.

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

    Regards

  7. Anna Kozlova says:

    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:

    The font is default (Tahoma 11)

  9. JohnPaul says:

    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:

    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:

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

  12. Anna Kozlova says:

    Davide, what support do you expect? Thanks

  13. David Turanski says:

    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:

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

Leave a Reply

Your email address will not be published. Required fields are marked *

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>