IntelliJ Idea 14 with Lambda Expression (bug)

The folowing code runs with IntelliJ IDEA 13.1.5 and Eclipse Luna but fails with IntelliJ IDEA 14

linux opensuse 13.2 x86_64
Java(TM) SE Runtime Environment (build 1.8.0_25-b17)



import java.util.*;

class ProductSqRoots {
    public static void main(String[] args) {
        ArrayList<Double> myList = new ArrayList<>( );
        myList.add(4.0);
        myList.add(9.0);
        double productOfSqrRoots =0;

        productOfSqrRoots = myList.parallelStream().reduce(               //failure
                1.0,
                (a,b) -> a * Math.sqrt(b),
                (a,b) -> a + b
        );

        System.out.println("Product of square roots: " + productOfSqrRoots);
    }
}



Information:Using javac 1.8.0_25 to compile java sources
Information:java: An exception has occurred in the compiler (1.8.0_25). Please file a bug at the Java Developer Connection (http://java.sun.com/webapps/bugreport)  after checking the Bug Parade for duplicates. Include your program and the following diagnostic in your report.  Thank you.
Information:java: java.lang.NullPointerException
Information:java:     at com.sun.tools.javac.code.Types.isConvertible(Types.java:290)
Information:java:     at com.sun.tools.javac.comp.Check.assertConvertible(Check.java:922)
Information:java:     at com.sun.tools.javac.comp.Check.checkMethod(Check.java:876)
Information:java:     at com.sun.tools.javac.comp.Attr.checkMethod(Attr.java:3838)
Information:java:     at com.sun.tools.javac.comp.Attr.checkIdInternal(Attr.java:3615)
Information:java:     at com.sun.tools.javac.comp.Attr.checkMethodIdInternal(Attr.java:3522)
Information:java:     at com.sun.tools.javac.comp.Attr.checkMethodId(Attr.java:3501)
Information:java:     at com.sun.tools.javac.comp.Attr.checkId(Attr.java:3488)
Information:java:     at com.sun.tools.javac.comp.Attr.visitSelect(Attr.java:3370)
Information:java:     at com.sun.tools.javac.tree.JCTree$JCFieldAccess.accept(JCTree.java:1897)
Information:java:     at com.sun.tools.javac.comp.Attr.attribTree(Attr.java:607)
Information:java:     at com.sun.tools.javac.comp.Attr.visitApply(Attr.java:1843)
Information:java:     at com.sun.tools.javac.tree.JCTree$JCMethodInvocation.accept(JCTree.java:1465)
Information:java:     at com.sun.tools.javac.comp.Attr.attribExpr(Attr.java:649)
Information:java:     at com.sun.tools.javac.comp.Attr.visitAssign(Attr.java:3000)
Information:java:     at com.sun.tools.javac.tree.JCTree$JCAssign.accept(JCTree.java:1686)
Information:java:     at com.sun.tools.javac.comp.Attr.attribExpr(Attr.java:656)
Information:java:     at com.sun.tools.javac.comp.Attr.visitExec(Attr.java:1611)
Information:java:     at com.sun.tools.javac.tree.JCTree$JCExpressionStatement.accept(JCTree.java:1296)
Information:java:     at com.sun.tools.javac.comp.Attr.attribStat(Attr.java:676)
Information:java:     at com.sun.tools.javac.comp.Attr.attribStats(Attr.java:692)
Information:java:     at com.sun.tools.javac.comp.Attr.visitBlock(Attr.java:1142)
Information:java:     at com.sun.tools.javac.tree.JCTree$JCBlock.accept(JCTree.java:909)
Information:java:     at com.sun.tools.javac.comp.Attr.visitMethodDef(Attr.java:1035)
Information:java:     at com.sun.tools.javac.tree.JCTree$JCMethodDecl.accept(JCTree.java:778)
Information:java:     at com.sun.tools.javac.comp.Attr.attribClassBody(Attr.java:4342)
Information:java:     at com.sun.tools.javac.comp.Attr.attribClass(Attr.java:4252)
Information:java:     at com.sun.tools.javac.comp.Attr.attribClass(Attr.java:4181)
Information:java:     at com.sun.tools.javac.comp.Attr.attrib(Attr.java:4156)
Information:java:     at com.sun.tools.javac.main.JavaCompiler.attribute(JavaCompiler.java:1248)
Information:java:     at com.sun.tools.javac.main.JavaCompiler.compile2(JavaCompiler.java:901)
Information:java:     at com.sun.tools.javac.main.JavaCompiler.compile(JavaCompiler.java:860)
Information:java:     at com.sun.tools.javac.main.Main.compile(Main.java:523)
Information:java:     at com.sun.tools.javac.api.JavacTaskImpl.doCall(JavacTaskImpl.java:129)
Information:java:     at com.sun.tools.javac.api.JavacTaskImpl.call(JavacTaskImpl.java:138)
Information:java:     at org.jetbrains.jps.javac.JavacMain.compile(JavacMain.java:165)
Information:java:     at org.jetbrains.jps.incremental.java.JavaBuilder.compileJava(JavaBuilder.java:380)
Information:java:     at org.jetbrains.jps.incremental.java.JavaBuilder.compile(JavaBuilder.java:298)
Information:java:     at org.jetbrains.jps.incremental.java.JavaBuilder.doBuild(JavaBuilder.java:204)
Information:java:     at org.jetbrains.jps.incremental.java.JavaBuilder.build(JavaBuilder.java:176)
Information:java:     at org.jetbrains.jps.incremental.IncProjectBuilder.runModuleLevelBuilders(IncProjectBuilder.java:1140)
Information:java:     at org.jetbrains.jps.incremental.IncProjectBuilder.runBuildersForChunk(IncProjectBuilder.java:826)
Information:java:     at org.jetbrains.jps.incremental.IncProjectBuilder.buildTargetsChunk(IncProjectBuilder.java:894)
Information:java:     at org.jetbrains.jps.incremental.IncProjectBuilder.buildChunkIfAffected(IncProjectBuilder.java:789)
Information:java:     at org.jetbrains.jps.incremental.IncProjectBuilder.buildChunks(IncProjectBuilder.java:612)
Information:java:     at org.jetbrains.jps.incremental.IncProjectBuilder.runBuild(IncProjectBuilder.java:352)
Information:java:     at org.jetbrains.jps.incremental.IncProjectBuilder.build(IncProjectBuilder.java:191)
Information:java:     at org.jetbrains.jps.cmdline.BuildRunner.runBuild(BuildRunner.java:131)
Information:java:     at org.jetbrains.jps.cmdline.BuildSession.runBuild(BuildSession.java:229)
Information:java:     at org.jetbrains.jps.cmdline.BuildSession.run(BuildSession.java:113)
Information:java:     at org.jetbrains.jps.cmdline.BuildMain$MyMessageHandler$1.run(BuildMain.java:158)
Information:java:     at org.jetbrains.jps.service.impl.SharedThreadPoolImpl$1.run(SharedThreadPoolImpl.java:41)
Information:java:     at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:511)
Information:java:     at java.util.concurrent.FutureTask.run(FutureTask.java:266)
Information:java:     at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1142)
Information:java:     at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:617)
Information:java:     at java.lang.Thread.run(Thread.java:745)
Information:java: Errors occurred while compiling module 'BookJDK8'
Information:28/11/14 23:26 - Compilation completed with 1 error and 0 warnings in 2 sec
Error:java: Compilation failed: internal java compiler error

1 comment
Comment actions Permalink

Hello.

This is an exception from javac. This means that javac, included into JDK 1.8.0_25 has a bug.

The issue seems to be filed to Java tracker: https://bugs.openjdk.java.net/browse/JDK-8062253 The latest response (see there) is that update 40 will contain the fix. But the latest public version of JDK is still update 25  (http://www.oracle.com/technetwork/java/javase/downloads/index.html), so  we just have to wait for update from Oracle.

Regards,
Alexander.

0

Please sign in to leave a comment.