Check lambda support in IntelliJ IDEA 12 EAP build 122.202
August 24th, 2012 by Maxim MossienkoA 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.




August 24th, 2012 at 12:48 pm
No way. Just No way! Niice
August 24th, 2012 at 7:55 pm
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
August 25th, 2012 at 10:34 pm
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
August 27th, 2012 at 3:50 am
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.
August 27th, 2012 at 5:01 am
What’s the font in the picture?
August 27th, 2012 at 1:41 pm
Thank you Anna
It works.
Regarding the other issue, is it a JDK-1.8 issue or IDE one?
Regards
August 28th, 2012 at 1:40 am
Hi,. strs = new TreeSet ((o1, o2) -> {
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
return o2.compareToIgnoreCase(o1);
});
{code}
compile but is highlighted in the IDE. Will investigate the problem. Thanks
August 30th, 2012 at 12:57 pm
The font is default (Tahoma 11)
September 19th, 2012 at 3:34 am
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?
September 21st, 2012 at 3:04 am
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
December 11th, 2012 at 10:57 am
is there already also support for map, filter and reduce operations on collections? Looks great anyway! Great job.
December 12th, 2012 at 5:38 am
Davide, what support do you expect? Thanks
March 19th, 2013 at 9:16 am
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?
March 19th, 2013 at 11:15 am
To be sure you need to download java from http://jdk8.java.net/lambda/.