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

javac crashes at com.sun.tools.javac.code.Types$7.visitType with AssertionError

    XMLWordPrintable

    Details

    • Type: Bug
    • Status: Closed
    • Priority: P4
    • Resolution: Duplicate
    • Affects Version/s: 11
    • Fix Version/s: None
    • Component/s: tools
    • Subcomponent:
    • CPU:
      x86_64
    • OS:
      generic
    • Verification:
      Not verified

      Description

      A DESCRIPTION OF THE PROBLEM :
      The javac crashes at "com.sun.tools.javac.code.Types$7.visitType" when trying to compile an incorrect program. I would expect javac to produce an error instead.

      Pasting the error messages below. Also attached the source code with the bug report.

      java.lang.AssertionError
              at jdk.compiler/com.sun.tools.javac.code.Types$7.visitType(Types.java:1676)
              at jdk.compiler/com.sun.tools.javac.code.Types$7.visitType(Types.java:1659)
              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.isCastable(Types.java:1650)
              at jdk.compiler/com.sun.tools.javac.comp.Attr$7.compatible(Attr.java:3431)
              at jdk.compiler/com.sun.tools.javac.comp.Check.checkType(Check.java:563)
              at jdk.compiler/com.sun.tools.javac.comp.Attr$ResultInfo.check(Attr.java:518)
              at jdk.compiler/com.sun.tools.javac.comp.Attr.check(Attr.java:250)
              at jdk.compiler/com.sun.tools.javac.comp.Attr.visitParens(Attr.java:3324)
              at jdk.compiler/com.sun.tools.javac.tree.JCTree$JCParens.accept(JCTree.java:1851)
              at jdk.compiler/com.sun.tools.javac.comp.Attr.attribTree(Attr.java:655)
              at jdk.compiler/com.sun.tools.javac.comp.Attr.visitTypeCast(Attr.java:3438)
              at jdk.compiler/com.sun.tools.javac.tree.JCTree$JCTypeCast.accept(JCTree.java:2022)
              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:486)
              at jdk.compiler/com.sun.tools.javac.comp.Attr.isBooleanOrNumeric(Attr.java:1647)
              at jdk.compiler/com.sun.tools.javac.comp.Attr.isBooleanOrNumeric(Attr.java:1626)
              at jdk.compiler/com.sun.tools.javac.comp.Attr.visitConditional(Attr.java:1588)
              at jdk.compiler/com.sun.tools.javac.tree.JCTree$JCConditional.accept(JCTree.java:1385)
              at jdk.compiler/com.sun.tools.javac.comp.Attr.attribTree(Attr.java:655)
              at jdk.compiler/com.sun.tools.javac.comp.Attr.visitParens(Attr.java:3323)
              at jdk.compiler/com.sun.tools.javac.tree.JCTree$JCParens.accept(JCTree.java:1851)
              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.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 :
      javac Test.java

      EXPECTED VERSUS ACTUAL BEHAVIOR :
      EXPECTED -
      A helpful error message.
      ACTUAL -
      crash.

      ---------- BEGIN SOURCE ----------
      public class Test
      {
        static final Double foo() {
          Double bar = 1.1;
          return ((true) ? bar : (Double) (() -> 10.0));
        }
      }
      ---------- END SOURCE ----------

      FREQUENCY : always


        Attachments

          Issue Links

            Activity

              People

              Assignee:
              adev ANUPAM DEV
              Reporter:
              webbuggrp Webbug Group
              Votes:
              0 Vote for this issue
              Watchers:
              2 Start watching this issue

                Dates

                Created:
                Updated:
                Resolved: