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

NullPointerException in javac compiling simple expression with reduce()

XMLWordPrintable

    • Icon: Bug Bug
    • Resolution: Duplicate
    • Icon: P4 P4
    • None
    • 8u31
    • tools
    • x86_64
    • linux

      FULL PRODUCT VERSION :
      java version "1.8.0_31"
      Java(TM) SE Runtime Environment (build 1.8.0_31-b13)
      Java HotSpot(TM) 64-Bit Server VM (build 25.31-b07, mixed mode)


      ADDITIONAL OS VERSION INFORMATION :
      Fedora 21 64

      A DESCRIPTION OF THE PROBLEM :
      See https://bugs.openjdk.java.net/browse/JDK-8072751. The bug was closed as duplicate and the original bug was closed as 'unreproducible' ... so it is still there unfixed.

      STEPS TO FOLLOW TO REPRODUCE THE PROBLEM :
      Try to compile following:



      import java.util.HashSet;
      import java.util.Set;
      import java.util.HashMap;
      import java.util.Map;

      public class Main {
          public static void main(String[] args) {
              Set<String> set = new HashSet<>();

              Map<String, String> map = set.stream().reduce(new HashMap<>(), Main::reduce/*(m, s) -> m*/, (r1, r2) -> null);
          }

          private static Map<String,String> reduce(Map<String,String> h, String s) {
              return h;
          }
      }

      EXPECTED VERSUS ACTUAL BEHAVIOR :
      EXPECTED -
      compilation succeed
      ACTUAL -
      Information:Using javac 1.8.0_31 to compile java sources
      Information:java: An exception has occurred in the compiler (1.8.0_31). 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.visitVarDef(Attr.java:1093)
      Information:java: at com.sun.tools.javac.tree.JCTree$JCVariableDecl.accept(JCTree.java:852)
      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:168)
      Information:java: at org.jetbrains.jps.incremental.java.JavaBuilder.compileJava(JavaBuilder.java:377)
      Information:java: at org.jetbrains.jps.incremental.java.JavaBuilder.compile(JavaBuilder.java:296)
      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:1142)
      Information:java: at org.jetbrains.jps.incremental.IncProjectBuilder.runBuildersForChunk(IncProjectBuilder.java:827)
      Information:java: at org.jetbrains.jps.incremental.IncProjectBuilder.buildTargetsChunk(IncProjectBuilder.java:895)
      Information:java: at org.jetbrains.jps.incremental.IncProjectBuilder.buildChunkIfAffected(IncProjectBuilder.java:790)
      Information:java: at org.jetbrains.jps.incremental.IncProjectBuilder.buildChunks(IncProjectBuilder.java:613)
      Information:java: at org.jetbrains.jps.incremental.IncProjectBuilder.runBuild(IncProjectBuilder.java:353)
      Information:java: at org.jetbrains.jps.incremental.IncProjectBuilder.build(IncProjectBuilder.java:192)
      Information:java: at org.jetbrains.jps.cmdline.BuildRunner.runBuild(BuildRunner.java:137)
      Information:java: at org.jetbrains.jps.cmdline.BuildSession.runBuild(BuildSession.java:288)
      Information:java: at org.jetbrains.jps.cmdline.BuildSession.run(BuildSession.java:123)
      Information:java: at org.jetbrains.jps.cmdline.BuildMain$MyMessageHandler$1.run(BuildMain.java:237)
      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)

      REPRODUCIBILITY :
      This bug can be reproduced always.

      ---------- BEGIN SOURCE ----------
      import java.util.HashSet;
      import java.util.Set;
      import java.util.HashMap;
      import java.util.Map;

      public class Main {
          public static void main(String[] args) {
              Set<String> set = new HashSet<>();

              Map<String, String> map = set.stream().reduce(new HashMap<>(), Main::reduce/*(m, s) -> m*/, (r1, r2) -> null);
          }

          private static Map<String,String> reduce(Map<String,String> h, String s) {
              return h;
          }
      }
      ---------- END SOURCE ----------

      CUSTOMER SUBMITTED WORKAROUND :
      use dev version of java 8u40

            Unassigned Unassigned
            webbuggrp Webbug Group
            Votes:
            0 Vote for this issue
            Watchers:
            3 Start watching this issue

              Created:
              Updated:
              Resolved: