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

Optional use inside optional.map breaks compiler

    Details

    • Subcomponent:
    • CPU:
      generic
    • OS:
      generic

      Description

      A DESCRIPTION OF THE PROBLEM :
      Optional.map to ifPresent set properties works in java 8 but fails in java 11.0.2

      REGRESSION : Last worked in version 8u201

      STEPS TO FOLLOW TO REPRODUCE THE PROBLEM :
      Always fails to compile

      EXPECTED VERSUS ACTUAL BEHAVIOR :
      EXPECTED -
      Compiler error or success
      ACTUAL -
      Information:java: compiler message file broken: key=compiler.misc.msg.bug arguments=11.0.2, {1}, {2}, {3}, {4}, {5}, {6}, {7}
      Information:java: at jdk.compiler/com.sun.tools.javac.util.Assert.check(Assert.java:46)
      Information:java: at jdk.compiler/com.sun.tools.javac.comp.DeferredAttr$2$1.setOverloadKind(DeferredAttr.java:172)
      Information:java: at jdk.compiler/com.sun.tools.javac.comp.ArgumentAttr.visitReference(ArgumentAttr.java:283)
      Information:java: at jdk.compiler/com.sun.tools.javac.tree.JCTree$JCMemberReference.accept(JCTree.java:2190)
      Information:java: at jdk.compiler/com.sun.tools.javac.comp.ArgumentAttr.attribArg(ArgumentAttr.java:197)
      Information:java: at jdk.compiler/com.sun.tools.javac.comp.Attr.attribTree(Attr.java:653)
      Information:java: at jdk.compiler/com.sun.tools.javac.comp.Attr.attribArgs(Attr.java:751)
      Information:java: at jdk.compiler/com.sun.tools.javac.comp.Attr.visitApply(Attr.java:1997)
      Information:java: at jdk.compiler/com.sun.tools.javac.tree.JCTree$JCMethodInvocation.accept(JCTree.java:1634)
      Information:java: at jdk.compiler/com.sun.tools.javac.comp.Attr.attribTree(Attr.java:655)
      Information:java: at jdk.compiler/com.sun.tools.javac.comp.Attr.attribExpr(Attr.java:702)
      Information:java: at jdk.compiler/com.sun.tools.javac.comp.Attr.visitExec(Attr.java:1773)
      Information:java: at jdk.compiler/com.sun.tools.javac.tree.JCTree$JCExpressionStatement.accept(JCTree.java:1452)
      Information:java: at jdk.compiler/com.sun.tools.javac.comp.Attr.attribStat(Attr.java:724)
      Information:java: at jdk.compiler/com.sun.tools.javac.comp.Attr.attribStats(Attr.java:743)
      Information:java: at jdk.compiler/com.sun.tools.javac.comp.Attr.visitLambda(Attr.java:2598)
      Information:java: at jdk.compiler/com.sun.tools.javac.tree.JCTree$JCLambda.accept(JCTree.java:1807)
      Information:java: at jdk.compiler/com.sun.tools.javac.comp.DeferredAttr$4.complete(DeferredAttr.java:374)
      Information:java: at jdk.compiler/com.sun.tools.javac.comp.DeferredAttr$DeferredType.check(DeferredAttr.java:335)
      Information:java: at jdk.compiler/com.sun.tools.javac.comp.DeferredAttr$DeferredType.check(DeferredAttr.java:321)
      Information:java: at jdk.compiler/com.sun.tools.javac.comp.Resolve$MethodResultInfo.check(Resolve.java:1060)
      Information:java: at jdk.compiler/com.sun.tools.javac.comp.Resolve$4.checkArg(Resolve.java:887)
      Information:java: at jdk.compiler/com.sun.tools.javac.comp.Resolve$AbstractMethodCheck.argumentsAcceptable(Resolve.java:775)
      Information:java: at jdk.compiler/com.sun.tools.javac.comp.Resolve$4.argumentsAcceptable(Resolve.java:896)
      Information:java: at jdk.compiler/com.sun.tools.javac.comp.Infer.instantiateMethod(Infer.java:181)
      Information:java: at jdk.compiler/com.sun.tools.javac.comp.Resolve.rawInstantiate(Resolve.java:605)
      Information:java: at jdk.compiler/com.sun.tools.javac.comp.Resolve.checkMethod(Resolve.java:644)
      Information:java: at jdk.compiler/com.sun.tools.javac.comp.Attr.checkMethod(Attr.java:4120)
      Information:java: at jdk.compiler/com.sun.tools.javac.comp.Attr.checkIdInternal(Attr.java:3913)
      Information:java: at jdk.compiler/com.sun.tools.javac.comp.Attr.checkMethodIdInternal(Attr.java:3814)
      Information:java: at jdk.compiler/com.sun.tools.javac.comp.Attr.checkId(Attr.java:3803)
      Information:java: at jdk.compiler/com.sun.tools.javac.comp.Attr.visitSelect(Attr.java:3696)
      Information:java: at jdk.compiler/com.sun.tools.javac.tree.JCTree$JCFieldAccess.accept(JCTree.java:2110)
      Information:java: at jdk.compiler/com.sun.tools.javac.comp.Attr.visitApply(Attr.java:2006)
      Information:java: at jdk.compiler/com.sun.tools.javac.comp.Attr.visitSelect(Attr.java:3573)
      Information:java: at jdk.compiler/com.sun.tools.javac.comp.DeferredAttr.attribSpeculative(DeferredAttr.java:498)
      Information:java: at jdk.compiler/com.sun.tools.javac.comp.DeferredAttr.attribSpeculative(DeferredAttr.java:481)
      Information:java: at jdk.compiler/com.sun.tools.javac.comp.ArgumentAttr.lambda$processArg$0(ArgumentAttr.java:220)
      Information:java: at jdk.compiler/com.sun.tools.javac.comp.ArgumentAttr.processArg(ArgumentAttr.java:242)
      Information:java: at jdk.compiler/com.sun.tools.javac.comp.ArgumentAttr.processArg(ArgumentAttr.java:219)
      Information:java: at jdk.compiler/com.sun.tools.javac.comp.ArgumentAttr.visitApply(ArgumentAttr.java:307)
      Information:java: at jdk.compiler/com.sun.tools.javac.comp.Attr.visitBlock(Attr.java:1294)
      Information:java: at jdk.compiler/com.sun.tools.javac.tree.JCTree$JCBlock.accept(JCTree.java:1020)
      Information:java: at jdk.compiler/com.sun.tools.javac.comp.Attr.visitMethodDef(Attr.java:1098)
      Information:java: at jdk.compiler/com.sun.tools.javac.tree.JCTree$JCMethodDecl.accept(JCTree.java:866)
      Information:java: at jdk.compiler/com.sun.tools.javac.comp.Attr.attribClassBody(Attr.java:4683)
      Information:java: at jdk.compiler/com.sun.tools.javac.comp.Attr.attribClass(Attr.java:4574)
      Information:java: at jdk.compiler/com.sun.tools.javac.comp.Attr.attribClass(Attr.java:4503)
      Information:java: at jdk.compiler/com.sun.tools.javac.comp.Attr.attrib(Attr.java:4448)
      Information:java: at jdk.compiler/com.sun.tools.javac.main.JavaCompiler.attribute(JavaCompiler.java:1341)
      Information:java: at jdk.compiler/com.sun.tools.javac.main.JavaCompiler.compile(JavaCompiler.java:973)
      Information:java: at jdk.compiler/com.sun.tools.javac.api.JavacTaskImpl.lambda$doCall$0(JavacTaskImpl.java:104)
      Information:java: at jdk.compiler/com.sun.tools.javac.api.JavacTaskImpl.handleExceptions(JavacTaskImpl.java:147)
      Information:java: at jdk.compiler/com.sun.tools.javac.api.JavacTaskImpl.doCall(JavacTaskImpl.java:100)
      Information:java: at jdk.compiler/com.sun.tools.javac.api.JavacTaskImpl.call(JavacTaskImpl.java:94)
      Information:java: at org.jetbrains.jps.javac.JavacMain.compile(JavacMain.java:196)
      Information:java: at org.jetbrains.jps.incremental.java.JavaBuilder.compileJava(JavaBuilder.java:448)
      Information:java: at org.jetbrains.jps.incremental.java.JavaBuilder.compile(JavaBuilder.java:318)
      Information:java: at org.jetbrains.jps.incremental.java.JavaBuilder.doBuild(JavaBuilder.java:243)
      Information:java: at org.jetbrains.jps.incremental.java.JavaBuilder.build(JavaBuilder.java:201)
      Information:java: at org.jetbrains.jps.incremental.IncProjectBuilder.runModuleLevelBuilders(IncProjectBuilder.java:1327)
      Information:java: at org.jetbrains.jps.incremental.IncProjectBuilder.runBuildersForChunk(IncProjectBuilder.java:1007)
      Information:java: at org.jetbrains.jps.incremental.IncProjectBuilder.buildTargetsChunk(IncProjectBuilder.java:1074)
      Information:java: at org.jetbrains.jps.incremental.IncProjectBuilder.buildChunkIfAffected(IncProjectBuilder.java:968)
      Information:java: at org.jetbrains.jps.incremental.IncProjectBuilder.buildChunks(IncProjectBuilder.java:797)
      Information:java: at org.jetbrains.jps.incremental.IncProjectBuilder.runBuild(IncProjectBuilder.java:375)
      Information:java: at org.jetbrains.jps.incremental.IncProjectBuilder.build(IncProjectBuilder.java:178)
      Information:java: at org.jetbrains.jps.cmdline.BuildRunner.runBuild(BuildRunner.java:138)
      Information:java: at org.jetbrains.jps.cmdline.BuildSession.runBuild(BuildSession.java:302)
      Information:java: at org.jetbrains.jps.cmdline.BuildSession.run(BuildSession.java:135)
      Information:java: at org.jetbrains.jps.cmdline.BuildMain$MyMessageHandler.lambda$channelRead0$0(BuildMain.java:229)
      Information:java: at org.jetbrains.jps.service.impl.SharedThreadPoolImpl.lambda$executeOnPooledThread$0(SharedThreadPoolImpl.java:42)
      Information:java: at java.base/java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:515)
      Information:java: at java.base/java.util.concurrent.FutureTask.run(FutureTask.java:264)
      Information:java: at java.base/java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1128)
      Information:java: at java.base/java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:628)
      Information:java: at java.base/java.lang.Thread.run(Thread.java:834)
      Information:java: Errors occurred while compiling module 'demo'
      Information:javac 11.0.2 was used to compile java sources
      Information:2019-03-15 01:32 - Compilation completed with 2 errors and 0 warnings in 2 s 818 ms
      Error:java: java.lang.AssertionError
      Error:java: at jdk.compiler/com.sun.tools.javac.util.Assert.error(Assert.java:155)

      ---------- BEGIN SOURCE ----------
      https://github.com/metron2/jdk-11-bug/blob/master/src/main/java/com/example/DemoApplication.java
      ---------- END SOURCE ----------

      CUSTOMER SUBMITTED WORKAROUND :
      Modify code

      FREQUENCY : always


        Attachments

          Issue Links

            Activity

              People

              • Assignee:
                pmangal Priyanka Mangal (Inactive)
                Reporter:
                webbuggrp Webbug Group
              • Votes:
                0 Vote for this issue
                Watchers:
                2 Start watching this issue

                Dates

                • Created:
                  Updated:
                  Resolved: