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

wrapper class object passed as parameter value of Stream.reduce method causes compiler assertionerror

    Details

    • Type: Bug
    • Status: Closed
    • Priority: P4
    • Resolution: Duplicate
    • Affects Version/s: 8u45
    • Fix Version/s: None
    • Component/s: tools
    • Subcomponent:
    • CPU:
      generic
    • OS:
      generic

      Description

      FULL PRODUCT VERSION :

      C:\javastudy\scjp\src\ch07>java -version
      java version "1.8.0_45"
      Java(TM) SE Runtime Environment (build 1.8.0_45-b15)
      Java HotSpot(TM) 64-Bit Server VM (build 25.45-b02, mixed mode)



      ADDITIONAL OS VERSION INFORMATION :
      Windows 10

      A DESCRIPTION OF THE PROBLEM :
      When invoking java.util.stream.Stream.reduce(U identity,
                   BiFunction<U,? super T,U> accumulator,
                   BinaryOperator<U> combiner) method with a wrapper class object(Integer, Double,...) as the parameter for identity, an assertionerror is thrown by the compiler. Identity when passed with other objects such as String does not throw assertionerror.

      EXPECTED VERSUS ACTUAL BEHAVIOR :
      EXPECTED -
      I expected it to compile with no problems.
      ACTUAL -

      An exception has occurred in the compiler (1.8.0_45). 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.
      java.lang.AssertionError: attribution shouldn't be happening here
              at com.sun.tools.javac.util.Assert.error(Assert.java:133)
              at com.sun.tools.javac.util.Assert.check(Assert.java:94)
              at com.sun.tools.javac.comp.DeferredAttr$DeferredAttrNode.process(DeferredAttr.java:591)
              at com.sun.tools.javac.comp.DeferredAttr$DeferredAttrContext.complete(DeferredAttr.java:479)
              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.checkMethod(Resolve.java:604)
              at com.sun.tools.javac.comp.Attr.checkMethod(Attr.java:3797)
              at com.sun.tools.javac.comp.Attr.checkIdInternal(Attr.java:3584)
              at com.sun.tools.javac.comp.Attr.checkMethodIdInternal(Attr.java:3491)
              at com.sun.tools.javac.comp.Attr.checkMethodId(Attr.java:3470)
              at com.sun.tools.javac.comp.Attr.checkId(Attr.java:3457)
              at com.sun.tools.javac.comp.Attr.visitSelect(Attr.java:3339)
              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:1806)
              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.DeferredAttr.attribSpeculative(DeferredAttr.java:386)
              at com.sun.tools.javac.comp.DeferredAttr$2.complete(DeferredAttr.java:279)
              at com.sun.tools.javac.comp.DeferredAttr$DeferredType.check(DeferredAttr.java:245)
              at com.sun.tools.javac.comp.DeferredAttr$DeferredType.check(DeferredAttr.java:232)
              at com.sun.tools.javac.comp.Resolve$MethodResultInfo.check(Resolve.java:1003)
              at com.sun.tools.javac.comp.Resolve$4.checkArg(Resolve.java:829)
              at com.sun.tools.javac.comp.Resolve$AbstractMethodCheck.argumentsAcceptable(Resolve.java:734)
              at com.sun.tools.javac.comp.Resolve$4.argumentsAcceptable(Resolve.java:838)
              at com.sun.tools.javac.comp.Resolve.rawInstantiate(Resolve.java:579)
              at com.sun.tools.javac.comp.Resolve.selectBest(Resolve.java:1441)
              at com.sun.tools.javac.comp.Resolve.findMethodInScope(Resolve.java:1628)
              at com.sun.tools.javac.comp.Resolve.findMethod(Resolve.java:1699)
              at com.sun.tools.javac.comp.Resolve.findMethod(Resolve.java:1672)
              at com.sun.tools.javac.comp.Resolve$9.doLookup(Resolve.java:2425)
              at com.sun.tools.javac.comp.Resolve$BasicLookupHelper.lookup(Resolve.java:3084)
              at com.sun.tools.javac.comp.Resolve.lookupMethod(Resolve.java:3335)
              at com.sun.tools.javac.comp.Resolve.resolveQualifiedMethod(Resolve.java:2422)
              at com.sun.tools.javac.comp.Resolve.resolveQualifiedMethod(Resolve.java:2416)
              at com.sun.tools.javac.comp.Attr.selectSym(Attr.java:3364)
              at com.sun.tools.javac.comp.Attr.visitSelect(Attr.java:3246)
              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:1806)
              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.visitExec(Attr.java:1574)
              at com.sun.tools.javac.tree.JCTree$JCExpressionStatement.accept(JCTree.java:1296)
              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.Attr.visitBlock(Attr.java:1105)
              at com.sun.tools.javac.tree.JCTree$JCBlock.accept(JCTree.java:909)
              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.visitMethodDef(Attr.java:994)
              at com.sun.tools.javac.tree.JCTree$JCMethodDecl.accept(JCTree.java:778)
              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:4330)
              at com.sun.tools.javac.comp.Attr.attribClass(Attr.java:4240)
              at com.sun.tools.javac.comp.Attr.attribClass(Attr.java:4169)
              at com.sun.tools.javac.comp.Attr.attrib(Attr.java:4144)
              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)



      ERROR MESSAGES/STACK TRACES THAT OCCUR :

      An exception has occurred in the compiler (1.8.0_45). 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.
      java.lang.AssertionError: attribution shouldn't be happening here
              at com.sun.tools.javac.util.Assert.error(Assert.java:133)
              at com.sun.tools.javac.util.Assert.check(Assert.java:94)
              at com.sun.tools.javac.comp.DeferredAttr$DeferredAttrNode.process(DeferredAttr.java:591)
              at com.sun.tools.javac.comp.DeferredAttr$DeferredAttrContext.complete(DeferredAttr.java:479)
              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.checkMethod(Resolve.java:604)
              at com.sun.tools.javac.comp.Attr.checkMethod(Attr.java:3797)
              at com.sun.tools.javac.comp.Attr.checkIdInternal(Attr.java:3584)
              at com.sun.tools.javac.comp.Attr.checkMethodIdInternal(Attr.java:3491)
              at com.sun.tools.javac.comp.Attr.checkMethodId(Attr.java:3470)
              at com.sun.tools.javac.comp.Attr.checkId(Attr.java:3457)
              at com.sun.tools.javac.comp.Attr.visitSelect(Attr.java:3339)
              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:1806)
              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.DeferredAttr.attribSpeculative(DeferredAttr.java:386)
              at com.sun.tools.javac.comp.DeferredAttr$2.complete(DeferredAttr.java:279)
              at com.sun.tools.javac.comp.DeferredAttr$DeferredType.check(DeferredAttr.java:245)
              at com.sun.tools.javac.comp.DeferredAttr$DeferredType.check(DeferredAttr.java:232)
              at com.sun.tools.javac.comp.Resolve$MethodResultInfo.check(Resolve.java:1003)
              at com.sun.tools.javac.comp.Resolve$4.checkArg(Resolve.java:829)
              at com.sun.tools.javac.comp.Resolve$AbstractMethodCheck.argumentsAcceptable(Resolve.java:734)
              at com.sun.tools.javac.comp.Resolve$4.argumentsAcceptable(Resolve.java:838)
              at com.sun.tools.javac.comp.Resolve.rawInstantiate(Resolve.java:579)
              at com.sun.tools.javac.comp.Resolve.selectBest(Resolve.java:1441)
              at com.sun.tools.javac.comp.Resolve.findMethodInScope(Resolve.java:1628)
              at com.sun.tools.javac.comp.Resolve.findMethod(Resolve.java:1699)
              at com.sun.tools.javac.comp.Resolve.findMethod(Resolve.java:1672)
              at com.sun.tools.javac.comp.Resolve$9.doLookup(Resolve.java:2425)
              at com.sun.tools.javac.comp.Resolve$BasicLookupHelper.lookup(Resolve.java:3084)
              at com.sun.tools.javac.comp.Resolve.lookupMethod(Resolve.java:3335)
              at com.sun.tools.javac.comp.Resolve.resolveQualifiedMethod(Resolve.java:2422)
              at com.sun.tools.javac.comp.Resolve.resolveQualifiedMethod(Resolve.java:2416)
              at com.sun.tools.javac.comp.Attr.selectSym(Attr.java:3364)
              at com.sun.tools.javac.comp.Attr.visitSelect(Attr.java:3246)
              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:1806)
              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.visitExec(Attr.java:1574)
              at com.sun.tools.javac.tree.JCTree$JCExpressionStatement.accept(JCTree.java:1296)
              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.Attr.visitBlock(Attr.java:1105)
              at com.sun.tools.javac.tree.JCTree$JCBlock.accept(JCTree.java:909)
              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.visitMethodDef(Attr.java:994)
              at com.sun.tools.javac.tree.JCTree$JCMethodDecl.accept(JCTree.java:778)
              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:4330)
              at com.sun.tools.javac.comp.Attr.attribClass(Attr.java:4240)
              at com.sun.tools.javac.comp.Attr.attribClass(Attr.java:4169)
              at com.sun.tools.javac.comp.Attr.attrib(Attr.java:4144)
              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.stream.*;
      import static java.util.stream.Collectors.*;
      import java.util.function.*;
      public class CollectorsTest{
      public static void main(String[] args){
      System.out.println(Stream.of(args).map(Integer::new).reduce(new Integer(1),(a,b)->a+b,(a,b)->a+b));
      }
      }
      ---------- END SOURCE ----------

        Attachments

          Issue Links

            Activity

              People

              • Assignee:
                fmatte Fairoz Matte
                Reporter:
                webbuggrp Webbug Group
              • Votes:
                0 Vote for this issue
                Watchers:
                2 Start watching this issue

                Dates

                • Created:
                  Updated:
                  Resolved: