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

Compile Failure with Stream processing and String Concatenation

XMLWordPrintable

    • Icon: Bug Bug
    • Resolution: Duplicate
    • Icon: P4 P4
    • None
    • 8
    • tools
    • x86_64
    • generic

      FULL PRODUCT VERSION :
      java version "1.8.0_60"
      Java(TM) SE Runtime Environment (build 1.8.0_60-b27)
      Java HotSpot(TM) 64-Bit Server VM (build 25.60-b23, mixed mode)

      ADDITIONAL OS VERSION INFORMATION :
      3.13.0-24-generic #46-Ubuntu SMP Thu Apr 10 19:11:08 UTC 2014 x86_64 x86_64 x86_64 GNU/Linux

      A DESCRIPTION OF THE PROBLEM :
      Getting a compiler error when attempting to compile the attached code. Appending the string seems to be important, also including the curly braces is important. If you switch it to an expression like map(c -> c) then there will be a StackOverflowError instead.

      STEPS TO FOLLOW TO REPRODUCE THE PROBLEM :
      Compile the attached code.

      EXPECTED VERSUS ACTUAL BEHAVIOR :
      EXPECTED -
      No Compile error
      ACTUAL -
      An exception has occurred in the compiler (1.8.0_60). Please file a bug at the Java Bug Database (http://bugreport.java.com/bugreport/) after checking the database for duplicates. Include your program and the following diagnostic in your report. Thank you.
              java.lang.AssertionError: java.lang.NullPointerException
              at com.sun.tools.javac.code.Symbol$VarSymbol.getConstValue(Symbol.java:1284)
              at com.sun.tools.javac.comp.Attr.visitVarDef(Attr.java:1048)
              at com.sun.tools.javac.tree.JCTree$JCVariableDecl.accept(JCTree.java:852)
              at com.sun.tools.javac.comp.Attr.attribTree(Attr.java:566)
              at com.sun.tools.javac.comp.Attr.attribStat(Attr.java:635)
              at com.sun.tools.javac.comp.Attr.attribClassBody(Attr.java:4341)
              at com.sun.tools.javac.comp.Attr.attribClass(Attr.java:4249)
              at com.sun.tools.javac.comp.Attr.attribClass(Attr.java:4178)
              at com.sun.tools.javac.comp.Attr.attrib(Attr.java:4153)
              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)
              Caused by: java.lang.NullPointerException
              at com.sun.tools.javac.comp.Attr.visitVarDef(Attr.java:1038)
              at com.sun.tools.javac.tree.JCTree$JCVariableDecl.accept(JCTree.java:852)
              at com.sun.tools.javac.comp.Attr.attribTree(Attr.java:566)
              at com.sun.tools.javac.comp.Attr.attribStat(Attr.java:635)
              at com.sun.tools.javac.comp.Attr.attribStats(Attr.java:651)
              at com.sun.tools.javac.comp.DeferredAttr$DeferredAttrNode$StructuralStuckChecker.canLambdaBodyCompleteNormally(DeferredAttr.java:695)
              at com.sun.tools.javac.comp.DeferredAttr$DeferredAttrNode$StructuralStuckChecker.visitLambda(DeferredAttr.java:664)
              at com.sun.tools.javac.tree.JCTree$JCLambda.accept(JCTree.java:1624)
              at com.sun.tools.javac.comp.DeferredAttr$DeferredAttrNode$StructuralStuckChecker.complete(DeferredAttr.java:617)
              at com.sun.tools.javac.comp.DeferredAttr$DeferredType.check(DeferredAttr.java:246)
              at com.sun.tools.javac.comp.DeferredAttr$DeferredType.access$100(DeferredAttr.java:132)
              at com.sun.tools.javac.comp.DeferredAttr$DeferredAttrNode.process(DeferredAttr.java:564)
              at com.sun.tools.javac.comp.DeferredAttr$DeferredAttrContext.complete(DeferredAttr.java:480)
              at com.sun.tools.javac.comp.Infer.instantiateMethod(Infer.java:182)
              at com.sun.tools.javac.comp.Resolve.rawInstantiate(Resolve.java:567)
              at com.sun.tools.javac.comp.Resolve.selectBest(Resolve.java:1440)
              at com.sun.tools.javac.comp.Resolve.findMethodInScope(Resolve.java:1627)
              at com.sun.tools.javac.comp.Resolve.findMethod(Resolve.java:1698)
              at com.sun.tools.javac.comp.Resolve.findMethod(Resolve.java:1671)
              at com.sun.tools.javac.comp.Resolve$9.doLookup(Resolve.java:2424)
              at com.sun.tools.javac.comp.Resolve$BasicLookupHelper.lookup(Resolve.java:3083)
              at com.sun.tools.javac.comp.Resolve.lookupMethod(Resolve.java:3334)
              at com.sun.tools.javac.comp.Resolve.resolveQualifiedMethod(Resolve.java:2421)
              at com.sun.tools.javac.comp.Resolve.resolveQualifiedMethod(Resolve.java:2415)
              at com.sun.tools.javac.comp.Attr.selectSym(Attr.java:3373)
              at com.sun.tools.javac.comp.Attr.visitSelect(Attr.java:3255)
              at com.sun.tools.javac.tree.JCTree$JCFieldAccess.accept(JCTree.java:1897)
              at com.sun.tools.javac.comp.Attr.attribTree(Attr.java:566)
              at com.sun.tools.javac.comp.Attr.visitApply(Attr.java:1815)
              at com.sun.tools.javac.tree.JCTree$JCMethodInvocation.accept(JCTree.java:1465)
              at com.sun.tools.javac.comp.Attr.attribTree(Attr.java:566)
              at com.sun.tools.javac.comp.Attr.visitSelect(Attr.java:3227)
              at com.sun.tools.javac.tree.JCTree$JCFieldAccess.accept(JCTree.java:1897)
              at com.sun.tools.javac.comp.Attr.attribTree(Attr.java:566)
              at com.sun.tools.javac.comp.Attr.visitApply(Attr.java:1815)
              at com.sun.tools.javac.tree.JCTree$JCMethodInvocation.accept(JCTree.java:1465)
              at com.sun.tools.javac.comp.Attr.attribTree(Attr.java:566)
              at com.sun.tools.javac.comp.Attr.attribExpr(Attr.java:615)
              at com.sun.tools.javac.comp.Attr.visitBinary(Attr.java:3033)
              at com.sun.tools.javac.tree.JCTree$JCBinary.accept(JCTree.java:1785)
              at com.sun.tools.javac.comp.Attr.attribTree(Attr.java:566)
              at com.sun.tools.javac.comp.Attr.attribExpr(Attr.java:608)
              at com.sun.tools.javac.comp.Attr.attribLazyConstantValue(Attr.java:750)
              at com.sun.tools.javac.code.Symbol$VarSymbol$2.call(Symbol.java:1250)
              at com.sun.tools.javac.code.Symbol$VarSymbol.getConstValue(Symbol.java:1282)
              ... 17 more


      REPRODUCIBILITY :
      This bug can be reproduced always.

      ---------- BEGIN SOURCE ----------
      import java.util.Arrays;
      import java.util.List;

      import static java.util.stream.Collectors.joining;

      public class CompilerError {

          private static final List<String> LIST = Arrays.asList("1", "2");

          public static final String CONCAT = LIST.stream().map(c -> c).collect(joining(",")) + "bang";

          public static void main(String[] args) {
              System.out.println(CONCAT);
          }

      }

      ---------- END SOURCE ----------

      CUSTOMER SUBMITTED WORKAROUND :
      If i make the CONCAT variable non-final, it compiles.

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

              Created:
              Updated:
              Resolved: