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

preflow visitor used during lambda attribution shouldn't visit class definitions inside the lambda body

    Details

    • Type: Bug
    • Status: Closed
    • Priority: P2
    • Resolution: Fixed
    • Affects Version/s: 9, 10, 10.0.1, 11
    • Fix Version/s: 12
    • Component/s: tools
    • Subcomponent:
    • Resolved In Build:
      b22
    • CPU:
      x86_64
    • OS:
      generic
    • Verification:
      Verified

      Description

      ADDITIONAL SYSTEM INFORMATION :
      Linux (4.9.96-1-MANJARO) x86_64
      OpenJDK 64-Bit Server VM (build 10.0.1+10, mixed mode)
      and also OpenJDK 64-Bit Server VM (build 9.0.4+11, mixed mode)

      A DESCRIPTION OF THE PROBLEM :
      On complex diamond type inference, javac raise an exception without giving any information on the cause of the inference exception

      REGRESSION : Last worked in version 8u172

      STEPS TO FOLLOW TO REPRODUCE THE PROBLEM :
      compile the class associated to the report.
      guava-24.0 is required in the classpath

      $ javac -classpath guava-24.0-jre.jar TestFail.java

      EXPECTED VERSUS ACTUAL BEHAVIOR :
      EXPECTED -
      It compile or at least give interesting information about the cause and location of the failure
      ACTUAL -
      An exception has occurred in the compiler (9.0.4). Please file a bug against the Java compiler via the Java bug reporting page (http://bugreport.java.com) after checking the Bug Database (http://bugs.java.com) for duplicates. Include your program and the following diagnostic in your report. Thank you.
      java.lang.AssertionError: isSubtype UNKNOWN
      at jdk.compiler/com.sun.tools.javac.code.Types$4.visitType(Types.java:803)
      at jdk.compiler/com.sun.tools.javac.code.Types$4.visitType(Types.java:780)
      at jdk.compiler/com.sun.tools.javac.code.Type.accept(Type.java:214)
      at jdk.compiler/com.sun.tools.javac.code.Types$DefaultTypeVisitor.visit(Types.java:4614)
      at jdk.compiler/com.sun.tools.javac.code.Types.isSubtype(Types.java:776)
      at jdk.compiler/com.sun.tools.javac.code.Types.isSubtypeUncheckedInternal(Types.java:702)
      at jdk.compiler/com.sun.tools.javac.code.Types.isSubtypeUnchecked(Types.java:688)
      at jdk.compiler/com.sun.tools.javac.code.Types.isConvertible(Types.java:311)
      at jdk.compiler/com.sun.tools.javac.code.Types.isAssignable(Types.java:2070)
      at jdk.compiler/com.sun.tools.javac.comp.Check$1.compatible(Check.java:536)
      at jdk.compiler/com.sun.tools.javac.comp.Check.checkType(Check.java:577)
      at jdk.compiler/com.sun.tools.javac.comp.Check.checkType(Check.java:564)
      at jdk.compiler/com.sun.tools.javac.comp.Annotate.attributeAnnotationValues(Annotate.java:452)
      at jdk.compiler/com.sun.tools.javac.comp.Annotate.attributeAnnotation(Annotate.java:408)
      at jdk.compiler/com.sun.tools.javac.comp.Annotate.annotateNow(Annotate.java:334)
      at jdk.compiler/com.sun.tools.javac.comp.Annotate.lambda$annotateLater$0(Annotate.java:260)
      at jdk.compiler/com.sun.tools.javac.comp.Annotate.flush(Annotate.java:184)
      at jdk.compiler/com.sun.tools.javac.comp.Annotate.unblockAnnotations(Annotate.java:137)
      at jdk.compiler/com.sun.tools.javac.comp.TypeEnter.complete(TypeEnter.java:210)
      at jdk.compiler/com.sun.tools.javac.code.Symbol.complete(Symbol.java:633)
      at jdk.compiler/com.sun.tools.javac.code.Symbol$ClassSymbol.complete(Symbol.java:1314)
      at jdk.compiler/com.sun.tools.javac.comp.Attr.visitClassDef(Attr.java:936)
      at jdk.compiler/com.sun.tools.javac.tree.JCTree$JCClassDecl.accept(JCTree.java:774)
      at jdk.compiler/com.sun.tools.javac.comp.Attr.attribTree(Attr.java:653)
      at jdk.compiler/com.sun.tools.javac.comp.Attr.attribStat(Attr.java:723)
      at jdk.compiler/com.sun.tools.javac.comp.Attr.visitAnonymousClassDefinition(Attr.java:2302)
      at jdk.compiler/com.sun.tools.javac.comp.Attr.lambda$visitAnonymousClassDefinition$2(Attr.java:2261)
      at jdk.compiler/com.sun.tools.javac.comp.InferenceContext.notifyChange(InferenceContext.java:265)
      at jdk.compiler/com.sun.tools.javac.comp.InferenceContext.notifyChange(InferenceContext.java:256)
      at jdk.compiler/com.sun.tools.javac.comp.Infer.instantiateMethod(Infer.java:248)
      at jdk.compiler/com.sun.tools.javac.comp.Resolve.rawInstantiate(Resolve.java:604)
      at jdk.compiler/com.sun.tools.javac.comp.Resolve.checkMethod(Resolve.java:643)
      at jdk.compiler/com.sun.tools.javac.comp.Attr.checkMethod(Attr.java:3998)
      at jdk.compiler/com.sun.tools.javac.comp.Attr.checkIdInternal(Attr.java:3791)
      at jdk.compiler/com.sun.tools.javac.comp.Attr.checkMethodIdInternal(Attr.java:3698)
      at jdk.compiler/com.sun.tools.javac.comp.Attr.checkMethodId(Attr.java:3677)
      at jdk.compiler/com.sun.tools.javac.comp.Attr.checkId(Attr.java:3664)
      at jdk.compiler/com.sun.tools.javac.comp.Attr.visitSelect(Attr.java:3549)
      at jdk.compiler/com.sun.tools.javac.tree.JCTree$JCFieldAccess.accept(JCTree.java:2104)
      at jdk.compiler/com.sun.tools.javac.comp.Attr.attribTree(Attr.java:653)
      at jdk.compiler/com.sun.tools.javac.comp.Attr.visitApply(Attr.java:1911)
      at jdk.compiler/com.sun.tools.javac.tree.JCTree$JCMethodInvocation.accept(JCTree.java:1628)
      at jdk.compiler/com.sun.tools.javac.comp.Attr.attribTree(Attr.java:653)
      at jdk.compiler/com.sun.tools.javac.comp.Attr.attribExpr(Attr.java:693)
      at jdk.compiler/com.sun.tools.javac.comp.Attr.visitVarDef(Attr.java:1155)
      at jdk.compiler/com.sun.tools.javac.tree.JCTree$JCVariableDecl.accept(JCTree.java:950)
      at jdk.compiler/com.sun.tools.javac.comp.Attr.attribTree(Attr.java:653)
      at jdk.compiler/com.sun.tools.javac.comp.Attr.attribStat(Attr.java:723)
      at jdk.compiler/com.sun.tools.javac.comp.Attr.attribStats(Attr.java:742)
      at jdk.compiler/com.sun.tools.javac.comp.Attr.visitBlock(Attr.java:1203)
      at jdk.compiler/com.sun.tools.javac.tree.JCTree$JCBlock.accept(JCTree.java:1014)
      at jdk.compiler/com.sun.tools.javac.comp.Attr.attribTree(Attr.java:653)
      at jdk.compiler/com.sun.tools.javac.comp.Attr.attribStat(Attr.java:723)
      at jdk.compiler/com.sun.tools.javac.comp.Attr.visitMethodDef(Attr.java:1094)
      at jdk.compiler/com.sun.tools.javac.tree.JCTree$JCMethodDecl.accept(JCTree.java:866)
      at jdk.compiler/com.sun.tools.javac.comp.Attr.attribTree(Attr.java:653)
      at jdk.compiler/com.sun.tools.javac.comp.Attr.attribStat(Attr.java:723)
      at jdk.compiler/com.sun.tools.javac.comp.Attr.attribClassBody(Attr.java:4562)
      at jdk.compiler/com.sun.tools.javac.comp.Attr.attribClass(Attr.java:4454)
      at jdk.compiler/com.sun.tools.javac.comp.Attr.attribClass(Attr.java:4383)
      at jdk.compiler/com.sun.tools.javac.comp.Attr.attrib(Attr.java:4328)
      at jdk.compiler/com.sun.tools.javac.main.JavaCompiler.attribute(JavaCompiler.java:1329)
      at jdk.compiler/com.sun.tools.javac.main.JavaCompiler.compile(JavaCompiler.java:959)
      at jdk.compiler/com.sun.tools.javac.main.Main.compile(Main.java:302)
      at jdk.compiler/com.sun.tools.javac.main.Main.compile(Main.java:162)
      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 ----------
      import java.util.List;
      import java.util.function.Function;

      import com.google.common.collect.Lists;

      public final class TestFail {
      public void build() {
      List<Function<String, Double>> partialComputers = Lists.transform(null, builder -> new Function<>() {
      @Override public Double apply(String params) { return null; }
      @Override public String toString() { return null; }
      });
      }
      }

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

      CUSTOMER SUBMITTED WORKAROUND :
      import java.util.List;
      import java.util.function.Function;

      import com.google.common.collect.Lists;

      public final class TestOk {

      public void build() {
      List<Function<String, Double>> partialComputers = Lists.transform(null, builder -> new Function<String, Double>() {
      @Override public Double apply(String params) { return null; }
      @Override public String toString() { return null; }
      });
      }
      }


      FREQUENCY : always


        Attachments

        1. TestFail.java
          0.4 kB
          Fairoz Matte

          Issue Links

            Activity

              People

              • Assignee:
                vromero Vicente Arturo Romero Zaldivar
                Reporter:
                webbuggrp Webbug Group
              • Votes:
                0 Vote for this issue
                Watchers:
                3 Start watching this issue

                Dates

                • Created:
                  Updated:
                  Resolved: