Uploaded image for project: 'JDK'
  1. JDK
  2. JDK-8044546

Crash on faulty reduce/lambda

    Details

    • Subcomponent:
    • Resolved In Build:
      b22
    • CPU:
      x86_64
    • OS:
      linux
    • Verification:
      Verified

      Backports

        Description

        FULL PRODUCT VERSION :
        java version "1.8.0_20-ea"
        Java(TM) SE Runtime Environment (build 1.8.0_20-ea-b15)
        Java HotSpot(TM) 64-Bit Server VM (build 25.20-b15, mixed mode)

        ADDITIONAL OS VERSION INFORMATION :
        Linux localhost 3.14.4-1-ARCH #1 SMP PREEMPT Tue May 13 16:41:39 CEST 2014 x86_64 GNU/Linux

        A DESCRIPTION OF THE PROBLEM :
        The compiler throws a NPE when it tries to compile my class containing the following line of code, which is likely malformed:
        "return Arrays.stream(data).reduce(true, (a,b) -> a && b.length == len, (a,b) -> true);".
        After commenting it out, it compiles just fine.

        The stacktrace is:
        java.lang.NullPointerException
        at com.sun.tools.javac.code.Types.isConvertible(Types.java:294)
        at com.sun.tools.javac.comp.Check.assertConvertible(Check.java:922)
        at com.sun.tools.javac.comp.Check.checkMethod(Check.java:876)
        at com.sun.tools.javac.comp.Attr.checkMethod(Attr.java:3818)
        at com.sun.tools.javac.comp.Attr.checkIdInternal(Attr.java:3595)
        at com.sun.tools.javac.comp.Attr.checkMethodIdInternal(Attr.java:3502)
        at com.sun.tools.javac.comp.Attr.checkMethodId(Attr.java:3481)
        at com.sun.tools.javac.comp.Attr.checkId(Attr.java:3468)
        at com.sun.tools.javac.comp.Attr.visitSelect(Attr.java:3350)
        at com.sun.tools.javac.tree.JCTree$JCFieldAccess.accept(JCTree.java:1897)
        at com.sun.tools.javac.comp.Attr.attribTree(Attr.java:600)
        at com.sun.tools.javac.comp.Attr.visitApply(Attr.java:1836)
        at com.sun.tools.javac.tree.JCTree$JCMethodInvocation.accept(JCTree.java:1465)
        at com.sun.tools.javac.comp.Attr.attribTree(Attr.java:600)
        at com.sun.tools.javac.comp.Attr.visitReturn(Attr.java:1697)
        at com.sun.tools.javac.tree.JCTree$JCReturn.accept(JCTree.java:1384)
        at com.sun.tools.javac.comp.Attr.attribTree(Attr.java:600)
        at com.sun.tools.javac.comp.Attr.attribStat(Attr.java:669)
        at com.sun.tools.javac.comp.Attr.attribStats(Attr.java:685)
        at com.sun.tools.javac.comp.Attr.visitBlock(Attr.java:1135)
        at com.sun.tools.javac.tree.JCTree$JCBlock.accept(JCTree.java:909)
        at com.sun.tools.javac.comp.Attr.attribTree(Attr.java:600)
        at com.sun.tools.javac.comp.Attr.attribStat(Attr.java:669)
        at com.sun.tools.javac.comp.Attr.visitMethodDef(Attr.java:1028)
        at com.sun.tools.javac.tree.JCTree$JCMethodDecl.accept(JCTree.java:778)
        at com.sun.tools.javac.comp.Attr.attribTree(Attr.java:600)
        at com.sun.tools.javac.comp.Attr.attribStat(Attr.java:669)
        at com.sun.tools.javac.comp.Attr.attribClassBody(Attr.java:4322)
        at com.sun.tools.javac.comp.Attr.attribClass(Attr.java:4232)
        at com.sun.tools.javac.comp.Attr.attribClass(Attr.java:4161)
        at com.sun.tools.javac.comp.Attr.attrib(Attr.java:4136)
        at com.sun.tools.javac.main.JavaCompiler.attribute(JavaCompiler.java:1248)
        at com.sun.tools.javac.main.JavaCompiler.compile2(JavaCompiler.java:901)
        at com.sun.tools.javac.main.JavaCompiler.compile(JavaCompiler.java:860)
        at com.sun.tools.javac.main.Main.compile(Main.java:523)
        at com.sun.tools.javac.main.Main.compile(Main.java:381)
        at com.sun.tools.javac.main.Main.compile(Main.java:370)
        at com.sun.tools.javac.main.Main.compile(Main.java:361)
        at com.sun.tools.javac.Main.compile(Main.java:56)
        at com.sun.tools.javac.Main.main(Main.java:42)

        STEPS TO FOLLOW TO REPRODUCE THE PROBLEM :
        Create a new class.
        Create a new method in this class, which returns a boolean and takes an array argument.called "data".
        Paste the following line in the method body: "return Arrays.stream(data).reduce(true, (a,b) -> a && b.length == len, (a,b) -> true);"
        Try to compile the class

        EXPECTED VERSUS ACTUAL BEHAVIOR :
        EXPECTED -
        An error message telling me why the code is malformed or successful compilation of the class if it isn't malformed.
        ACTUAL -
        A Null-Pointer Exception:


        ERROR MESSAGES/STACK TRACES THAT OCCUR :
        java.lang.NullPointerException
        at com.sun.tools.javac.code.Types.isConvertible(Types.java:294)
        at com.sun.tools.javac.comp.Check.assertConvertible(Check.java:922)
        at com.sun.tools.javac.comp.Check.checkMethod(Check.java:876)
        at com.sun.tools.javac.comp.Attr.checkMethod(Attr.java:3818)
        at com.sun.tools.javac.comp.Attr.checkIdInternal(Attr.java:3595)
        at com.sun.tools.javac.comp.Attr.checkMethodIdInternal(Attr.java:3502)
        at com.sun.tools.javac.comp.Attr.checkMethodId(Attr.java:3481)
        at com.sun.tools.javac.comp.Attr.checkId(Attr.java:3468)
        at com.sun.tools.javac.comp.Attr.visitSelect(Attr.java:3350)
        at com.sun.tools.javac.tree.JCTree$JCFieldAccess.accept(JCTree.java:1897)
        at com.sun.tools.javac.comp.Attr.attribTree(Attr.java:600)
        at com.sun.tools.javac.comp.Attr.visitApply(Attr.java:1836)
        at com.sun.tools.javac.tree.JCTree$JCMethodInvocation.accept(JCTree.java:1465)
        at com.sun.tools.javac.comp.Attr.attribTree(Attr.java:600)
        at com.sun.tools.javac.comp.Attr.visitReturn(Attr.java:1697)
        at com.sun.tools.javac.tree.JCTree$JCReturn.accept(JCTree.java:1384)
        at com.sun.tools.javac.comp.Attr.attribTree(Attr.java:600)
        at com.sun.tools.javac.comp.Attr.attribStat(Attr.java:669)
        at com.sun.tools.javac.comp.Attr.attribStats(Attr.java:685)
        at com.sun.tools.javac.comp.Attr.visitBlock(Attr.java:1135)
        at com.sun.tools.javac.tree.JCTree$JCBlock.accept(JCTree.java:909)
        at com.sun.tools.javac.comp.Attr.attribTree(Attr.java:600)
        at com.sun.tools.javac.comp.Attr.attribStat(Attr.java:669)
        at com.sun.tools.javac.comp.Attr.visitMethodDef(Attr.java:1028)
        at com.sun.tools.javac.tree.JCTree$JCMethodDecl.accept(JCTree.java:778)
        at com.sun.tools.javac.comp.Attr.attribTree(Attr.java:600)
        at com.sun.tools.javac.comp.Attr.attribStat(Attr.java:669)
        at com.sun.tools.javac.comp.Attr.attribClassBody(Attr.java:4322)
        at com.sun.tools.javac.comp.Attr.attribClass(Attr.java:4232)
        at com.sun.tools.javac.comp.Attr.attribClass(Attr.java:4161)
        at com.sun.tools.javac.comp.Attr.attrib(Attr.java:4136)
        at com.sun.tools.javac.main.JavaCompiler.attribute(JavaCompiler.java:1248)
        at com.sun.tools.javac.main.JavaCompiler.compile2(JavaCompiler.java:901)
        at com.sun.tools.javac.main.JavaCompiler.compile(JavaCompiler.java:860)
        at com.sun.tools.javac.main.Main.compile(Main.java:523)
        at com.sun.tools.javac.main.Main.compile(Main.java:381)
        at com.sun.tools.javac.main.Main.compile(Main.java:370)
        at com.sun.tools.javac.main.Main.compile(Main.java:361)
        at com.sun.tools.javac.Main.compile(Main.java:56)
        at com.sun.tools.javac.Main.main(Main.java:42)

        REPRODUCIBILITY :
        This bug can be reproduced always.

        ---------- BEGIN SOURCE ----------
        import java.util.Arrays;
                                                                                                                                              
        public class Test
        {
                public boolean asd(Object[] data)
                {
                        return Arrays.stream(data).reduce(true, (a,b) -> a && b.length == len, (a,b) -> true);
                }
        }
        ---------- END SOURCE ----------

          Attachments

            Issue Links

              Activity

                People

                • Assignee:
                  vromero Vicente Arturo Romero Zaldivar
                  Reporter:
                  webbuggrp Webbug Group
                • Votes:
                  0 Vote for this issue
                  Watchers:
                  6 Start watching this issue

                  Dates

                  • Created:
                    Updated:
                    Resolved: