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

Compiler exception when using lambda returning generic object

XMLWordPrintable

    • x86_64
    • generic

      ADDITIONAL SYSTEM INFORMATION :
      Ubuntu 64,
      I download java from repository ppa:linuxuprising/java

      A DESCRIPTION OF THE PROBLEM :
      javac bxlx/SandBox.java
      An exception has occurred in the compiler (11.0.1). 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:1123)
      at jdk.compiler/com.sun.tools.javac.code.Types$4.visitType(Types.java:1100)
      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:4857)
      at jdk.compiler/com.sun.tools.javac.code.Types.isSubtype(Types.java:1096)
      at jdk.compiler/com.sun.tools.javac.code.Types.isSubtypeUncheckedInternal(Types.java:1022)
      at jdk.compiler/com.sun.tools.javac.code.Types.isSubtypeUnchecked(Types.java:1008)
      at jdk.compiler/com.sun.tools.javac.code.Types.isConvertible(Types.java:607)
      at jdk.compiler/com.sun.tools.javac.code.Types.isAssignable(Types.java:2319)
      at jdk.compiler/com.sun.tools.javac.comp.Check$1.compatible(Check.java:522)
      at jdk.compiler/com.sun.tools.javac.comp.Check.checkType(Check.java:563)
      at jdk.compiler/com.sun.tools.javac.comp.Check.checkType(Check.java:550)
      at jdk.compiler/com.sun.tools.javac.comp.Annotate.attributeAnnotationValues(Annotate.java:459)
      at jdk.compiler/com.sun.tools.javac.comp.Annotate.attributeAnnotation(Annotate.java:415)
      at jdk.compiler/com.sun.tools.javac.comp.Annotate.annotateNow(Annotate.java:341)
      at jdk.compiler/com.sun.tools.javac.comp.Annotate.lambda$annotateLater$0(Annotate.java:267)
      at jdk.compiler/com.sun.tools.javac.comp.Annotate.flush(Annotate.java:191)
      at jdk.compiler/com.sun.tools.javac.comp.Annotate.unblockAnnotations(Annotate.java:144)
      at jdk.compiler/com.sun.tools.javac.comp.TypeEnter.complete(TypeEnter.java:213)
      at jdk.compiler/com.sun.tools.javac.code.Symbol.complete(Symbol.java:642)
      at jdk.compiler/com.sun.tools.javac.code.Symbol$ClassSymbol.complete(Symbol.java:1326)
      at jdk.compiler/com.sun.tools.javac.comp.Attr.visitClassDef(Attr.java:941)
      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:655)
      at jdk.compiler/com.sun.tools.javac.comp.Attr.attribStat(Attr.java:724)
      at jdk.compiler/com.sun.tools.javac.comp.Attr.visitAnonymousClassDefinition(Attr.java:2397)
      at jdk.compiler/com.sun.tools.javac.comp.Attr.lambda$visitAnonymousClassDefinition$2(Attr.java:2355)
      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.InferenceContext.lambda$min$5(InferenceContext.java:372)
      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.InferenceContext.lambda$dupTo$3(InferenceContext.java:332)
      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:242)
      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.visitIdent(Attr.java:3553)
      at jdk.compiler/com.sun.tools.javac.tree.JCTree$JCIdent.accept(JCTree.java:2243)
      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:702)
      at jdk.compiler/com.sun.tools.javac.comp.Attr.visitExec(Attr.java:1773)
      at jdk.compiler/com.sun.tools.javac.tree.JCTree$JCExpressionStatement.accept(JCTree.java:1452)
      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.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.visitMethodDef(Attr.java:1098)
      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: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)

      STEPS TO FOLLOW TO REPRODUCE THE PROBLEM :
      Try to compile bxlx.SandBox source with javac

      EXPECTED VERSUS ACTUAL BEHAVIOR :
      EXPECTED -
      bxlx.SandBox compiles
      ACTUAL -
      javac throws an exception

      ---------- BEGIN SOURCE ----------
      package bxlx;

      public class SandBox {
          
          public interface Callable<T> {
              T call();
          }

          public static <T> T get(Callable<T> c) {
              return null;
          }

          public static void main(String[] args) {
              get(() -> get(new Callable<>() {
                  @Override
                  public Object call() {
                      return get(this);
                  }
              }));
          }
      }
      ---------- END SOURCE ----------

      CUSTOMER SUBMITTED WORKAROUND :
      if the inside callable definition got a specific generic type (new Callable<Object>()), the problem is gone

      FREQUENCY : always


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

              Created:
              Updated:
              Resolved: