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

Some usage of method reference fails to compile

    Details

    • Subcomponent:
    • CPU:
      x86_64
    • OS:
      linux

      Description

      ADDITIONAL SYSTEM INFORMATION :
      $ export JAVA_HOME=${TRAVIS_HOME}/openjdk11
      $ bash install-jdk.sh -F 11 -L GPL --target $JAVA_HOME --workspace ${TRAVIS_HOME}/.cache/install-jdk
      install-jdk.sh 2018-08-16
      Variables:
        feature = 11
        license = GPL
             os = linux-x64
            url = https://download.java.net/java/early_access/jdk11/28/GPL/openjdk-11+28_linux-x64_bin.tar.gz
         status = 200
        archive = /home/travis/.cache/install-jdk/openjdk-11+28_linux-x64_bin.tar.gz
      Downloading JDK from https://download.java.net/java/early_access/jdk11/28/GPL/openjdk-11+28_linux-x64_bin.tar.gz...
      Picked up _JAVA_OPTIONS: -Xmx2048m -Xms512m
      openjdk version "11" 2018-09-25
      OpenJDK Runtime Environment 18.9 (build 11+28)
      OpenJDK 64-Bit Server VM 18.9 (build 11+28, mixed mode)

      A DESCRIPTION OF THE PROBLEM :
      The following class fails to compile under jdk11 and jdk12 (as provided by travis):
      ```
      package test;

      import java.math.BigInteger;
      import java.util.Optional;

      public class CompilerBug {
        public static final Optional<BigInteger> oi = Optional.of(BigInteger.TEN).flatMap(i -> {
          Optional<BigInteger> one = Optional.of(BigInteger.valueOf(1L));
          return Optional.of(BigInteger.valueOf(2L)).or(() -> one.map(i::subtract));
        });
      }
      ```
      switching last line to usie lambda synthax solve the issue.
      cf. https://github.com/jbgi/jdk11-big-integer-substract-bug/commit/8bab8e60202eb3e15bde379677324400b3397db2

      and logs: https://travis-ci.org/jbgi/jdk11-big-integer-substract-bug/jobs/428313549

      REGRESSION : Last worked in version 10.0.2

      STEPS TO FOLLOW TO REPRODUCE THE PROBLEM :
      echo "package test;
      import java.math.BigInteger;
      import java.util.Optional;
      public class CompilerBug {
        public static final Optional<BigInteger> oi = Optional.of(BigInteger.TEN).flatMap(i -> {
          Optional<BigInteger> one = Optional.of(BigInteger.valueOf(1L));
          return Optional.of(BigInteger.valueOf(2L)).or(() -> one.map(i::subtract));
        });
      }" > CompilerBug.java

      javac CompilerBug.java

      EXPECTED VERSUS ACTUAL BEHAVIOR :
      EXPECTED -
      file compile properly.
      ACTUAL -
      java.lang.AssertionError
      at jdk.compiler/com.sun.tools.javac.util.Assert.error(Assert.java:155)
      at jdk.compiler/com.sun.tools.javac.util.Assert.check(Assert.java:46)
      at jdk.compiler/com.sun.tools.javac.comp.DeferredAttr$2$1.setOverloadKind(DeferredAttr.java:172)
      at jdk.compiler/com.sun.tools.javac.comp.ArgumentAttr.visitReference(ArgumentAttr.java:283)
      at jdk.compiler/com.sun.tools.javac.tree.JCTree$JCMemberReference.accept(JCTree.java:2190)
      at jdk.compiler/com.sun.tools.javac.comp.ArgumentAttr.attribArg(ArgumentAttr.java:197)
      at jdk.compiler/com.sun.tools.javac.comp.Attr.attribTree(Attr.java:653)
      at jdk.compiler/com.sun.tools.javac.comp.Attr.attribArgs(Attr.java:751)
      at jdk.compiler/com.sun.tools.javac.comp.Attr.visitApply(Attr.java:1997)
      at jdk.compiler/com.sun.tools.javac.tree.JCTree$JCMethodInvocation.accept(JCTree.java:1634)
      at jdk.compiler/com.sun.tools.javac.comp.Attr.attribTree(Attr.java:655)
      at jdk.compiler/com.sun.tools.javac.comp.DeferredAttr.attribSpeculative(DeferredAttr.java:498)
      at jdk.compiler/com.sun.tools.javac.comp.DeferredAttr.attribSpeculative(DeferredAttr.java:481)
      at jdk.compiler/com.sun.tools.javac.comp.ArgumentAttr.lambda$processArg$0(ArgumentAttr.java:220)
      at jdk.compiler/com.sun.tools.javac.comp.ArgumentAttr.processArg(ArgumentAttr.java:242)
      at jdk.compiler/com.sun.tools.javac.comp.ArgumentAttr.processArg(ArgumentAttr.java:219)
      at jdk.compiler/com.sun.tools.javac.comp.ArgumentAttr.visitApply(ArgumentAttr.java:307)
      at jdk.compiler/com.sun.tools.javac.tree.JCTree$JCMethodInvocation.accept(JCTree.java:1634)
      at jdk.compiler/com.sun.tools.javac.comp.ArgumentAttr.attribArg(ArgumentAttr.java:197)
      at jdk.compiler/com.sun.tools.javac.comp.Attr.attribTree(Attr.java:653)
      at jdk.compiler/com.sun.tools.javac.comp.Attr.visitReturn(Attr.java:1866)
      at jdk.compiler/com.sun.tools.javac.tree.JCTree$JCReturn.accept(JCTree.java:1546)
      at jdk.compiler/com.sun.tools.javac.comp.Attr.attribTree(Attr.java:655)
      at jdk.compiler/com.sun.tools.javac.comp.Attr.attribStat(Attr.java:724)
      at jdk.compiler/com.sun.tools.javac.comp.Attr.attribStats(Attr.java:743)
      at jdk.compiler/com.sun.tools.javac.comp.Attr.visitBlock(Attr.java:1294)
      at jdk.compiler/com.sun.tools.javac.tree.JCTree$JCBlock.accept(JCTree.java:1020)
      at jdk.compiler/com.sun.tools.javac.comp.ArgumentAttr.visitTree(ArgumentAttr.java:207)
      at jdk.compiler/com.sun.tools.javac.tree.JCTree$Visitor.visitBlock(JCTree.java:3065)
      at jdk.compiler/com.sun.tools.javac.tree.JCTree$JCBlock.accept(JCTree.java:1020)
      at jdk.compiler/com.sun.tools.javac.comp.ArgumentAttr.attribArg(ArgumentAttr.java:197)
      at jdk.compiler/com.sun.tools.javac.comp.Attr.attribTree(Attr.java:653)
      at jdk.compiler/com.sun.tools.javac.comp.DeferredAttr.attribSpeculative(DeferredAttr.java:498)
      at jdk.compiler/com.sun.tools.javac.comp.DeferredAttr.attribSpeculative(DeferredAttr.java:481)
      at jdk.compiler/com.sun.tools.javac.comp.DeferredAttr.attribSpeculativeLambda(DeferredAttr.java:456)
      at jdk.compiler/com.sun.tools.javac.comp.ArgumentAttr.lambda$visitLambda$3(ArgumentAttr.java:295)
      at jdk.compiler/com.sun.tools.javac.comp.ArgumentAttr.processArg(ArgumentAttr.java:242)
      at jdk.compiler/com.sun.tools.javac.comp.ArgumentAttr.visitLambda(ArgumentAttr.java:293)
      at jdk.compiler/com.sun.tools.javac.tree.JCTree$JCLambda.accept(JCTree.java:1807)
      at jdk.compiler/com.sun.tools.javac.comp.ArgumentAttr.attribArg(ArgumentAttr.java:197)
      at jdk.compiler/com.sun.tools.javac.comp.Attr.attribTree(Attr.java:653)
      at jdk.compiler/com.sun.tools.javac.comp.Attr.attribArgs(Attr.java:751)
      at jdk.compiler/com.sun.tools.javac.comp.Attr.visitApply(Attr.java:1997)
      at jdk.compiler/com.sun.tools.javac.tree.JCTree$JCMethodInvocation.accept(JCTree.java:1634)
      at jdk.compiler/com.sun.tools.javac.comp.Attr.attribTree(Attr.java:655)
      at jdk.compiler/com.sun.tools.javac.comp.Attr.visitReturn(Attr.java:1866)
      at jdk.compiler/com.sun.tools.javac.tree.JCTree$JCReturn.accept(JCTree.java:1546)
      at jdk.compiler/com.sun.tools.javac.comp.Attr.attribTree(Attr.java:655)
      at jdk.compiler/com.sun.tools.javac.comp.Attr.attribStat(Attr.java:724)
      at jdk.compiler/com.sun.tools.javac.comp.Attr.attribStats(Attr.java:743)
      at jdk.compiler/com.sun.tools.javac.comp.Attr.visitLambda(Attr.java:2598)
      at jdk.compiler/com.sun.tools.javac.tree.JCTree$JCLambda.accept(JCTree.java:1807)
      at jdk.compiler/com.sun.tools.javac.comp.Attr.attribTree(Attr.java:655)
      at jdk.compiler/com.sun.tools.javac.comp.DeferredAttr$4.complete(DeferredAttr.java:374)
      at jdk.compiler/com.sun.tools.javac.comp.DeferredAttr$DeferredType.check(DeferredAttr.java:335)
      at jdk.compiler/com.sun.tools.javac.comp.DeferredAttr$DeferredType.check(DeferredAttr.java:321)
      at jdk.compiler/com.sun.tools.javac.comp.Resolve$MethodResultInfo.check(Resolve.java:1060)
      at jdk.compiler/com.sun.tools.javac.comp.Resolve$4.checkArg(Resolve.java:887)
      at jdk.compiler/com.sun.tools.javac.comp.Resolve$AbstractMethodCheck.argumentsAcceptable(Resolve.java:775)
      at jdk.compiler/com.sun.tools.javac.comp.Resolve$4.argumentsAcceptable(Resolve.java:896)
      at jdk.compiler/com.sun.tools.javac.comp.Infer.instantiateMethod(Infer.java:181)
      at jdk.compiler/com.sun.tools.javac.comp.Resolve.rawInstantiate(Resolve.java:605)
      at jdk.compiler/com.sun.tools.javac.comp.Resolve.checkMethod(Resolve.java:644)
      at jdk.compiler/com.sun.tools.javac.comp.Attr.checkMethod(Attr.java:4120)
      at jdk.compiler/com.sun.tools.javac.comp.Attr.checkIdInternal(Attr.java:3913)
      at jdk.compiler/com.sun.tools.javac.comp.Attr.checkMethodIdInternal(Attr.java:3814)
      at jdk.compiler/com.sun.tools.javac.comp.Attr.checkId(Attr.java:3803)
      at jdk.compiler/com.sun.tools.javac.comp.Attr.visitSelect(Attr.java:3696)
      at jdk.compiler/com.sun.tools.javac.tree.JCTree$JCFieldAccess.accept(JCTree.java:2110)
      at jdk.compiler/com.sun.tools.javac.comp.Attr.attribTree(Attr.java:655)
      at jdk.compiler/com.sun.tools.javac.comp.Attr.visitApply(Attr.java:2006)
      at jdk.compiler/com.sun.tools.javac.tree.JCTree$JCMethodInvocation.accept(JCTree.java:1634)
      at jdk.compiler/com.sun.tools.javac.comp.Attr.attribTree(Attr.java:655)
      at jdk.compiler/com.sun.tools.javac.comp.Attr.attribExpr(Attr.java:695)
      at jdk.compiler/com.sun.tools.javac.comp.Attr.visitVarDef(Attr.java:1174)
      at jdk.compiler/com.sun.tools.javac.tree.JCTree$JCVariableDecl.accept(JCTree.java:956)
      at jdk.compiler/com.sun.tools.javac.comp.Attr.attribTree(Attr.java:655)
      at jdk.compiler/com.sun.tools.javac.comp.Attr.attribStat(Attr.java:724)
      at jdk.compiler/com.sun.tools.javac.comp.Attr.attribClassBody(Attr.java:4683)
      at jdk.compiler/com.sun.tools.javac.comp.Attr.attribClass(Attr.java:4574)
      at jdk.compiler/com.sun.tools.javac.comp.Attr.attribClass(Attr.java:4503)
      at jdk.compiler/com.sun.tools.javac.comp.Attr.attrib(Attr.java:4448)
      at jdk.compiler/com.sun.tools.javac.main.JavaCompiler.attribute(JavaCompiler.java:1341)
      at jdk.compiler/com.sun.tools.javac.main.JavaCompiler.compile(JavaCompiler.java:973)
      at jdk.compiler/com.sun.tools.javac.main.Main.compile(Main.java:311)
      at jdk.compiler/com.sun.tools.javac.main.Main.compile(Main.java:170)
      at jdk.compiler/com.sun.tools.javac.Main.compile(Main.java:57)
      at jdk.compiler/com.sun.tools.javac.Main.main(Main.java:43)

      ---------- BEGIN SOURCE ----------
      https://github.com/jbgi/jdk11-big-integer-substract-bug
      ---------- END SOURCE ----------

      CUSTOMER SUBMITTED WORKAROUND :
      use lambda syntax instead of method reference:


      FREQUENCY : always


        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: