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

regression: javac silently crashes when resolving erroneous anonymous inner constructor

    Details

    • Type: Bug
    • Status: Closed
    • Priority: P3
    • Resolution: Fixed
    • Affects Version/s: 7
    • Fix Version/s: 7
    • Component/s: tools
    • Subcomponent:
    • Introduced In Build:
      b44
    • Introduced In Version:
      7
    • Resolved In Build:
      b70
    • CPU:
      unknown
    • OS:
      generic
    • Verification:
      Verified

      Description

      When compiling the following source:

      class Test {

          Test(Integer x) {}

          void test() {
              new Test(""){};
          }
      }

      javac silently crashes. The crash is reproducible when the above program is compiled with the -XDdev hidden option - otherwise the only observable difference in javac's behavior is that any diagnostic following the one that is causing the crash will not be generated by javac.

      Here's the javac output:

      /usr/local/home/maurizio/Desktop/TestX.java:6: cannot find symbol
      /usr/local/home/maurizio/Desktop/TestX.java:6: cannot find symbol
              new Test(""){};
              ^
        symbol: constructor Test(java.lang.String)
        location: class Test
      /usr/local/home/maurizio/Desktop/TestX.java:6: cannot find symbol
      /usr/local/home/maurizio/Desktop/TestX.java:6: cannot find symbol
              new Test(""){};
                          ^
        symbol: constructor Test()
        location: class Test
      An exception has occurred in the compiler (1.7.0-ea). Please file a bug at the Java Developer Connection (http://java.sun.com/webapps/bugreport) after checking the Bug Parade for duplicates. Include your program and the following diagnostic in your report. Thank you.
      java.lang.NullPointerException
              at com.sun.tools.javac.code.Types$14.visitClassType(Types.java:1339)
              at com.sun.tools.javac.code.Types$14.visitClassType(Types.java:1322)
              at com.sun.tools.javac.code.Type$ClassType.accept(Type.java:550)
              at com.sun.tools.javac.code.Types$DefaultTypeVisitor.visit(Types.java:3346)
              at com.sun.tools.javac.code.Types.asSuper(Types.java:1319)
              at com.sun.tools.javac.code.Types$14.visitClassType(Types.java:1335)
              at com.sun.tools.javac.code.Types$14.visitClassType(Types.java:1322)
              at com.sun.tools.javac.code.Type$ClassType.accept(Type.java:550)
              at com.sun.tools.javac.code.Types$DefaultTypeVisitor.visit(Types.java:3346)
              at com.sun.tools.javac.code.Types.asSuper(Types.java:1319)
              at com.sun.tools.javac.code.Types$14.visitClassType(Types.java:1335)
              at com.sun.tools.javac.code.Types$14.visitClassType(Types.java:1322)
              at com.sun.tools.javac.code.Type$ClassType.accept(Type.java:550)
              at com.sun.tools.javac.code.Types$DefaultTypeVisitor.visit(Types.java:3346)
              at com.sun.tools.javac.code.Types.asSuper(Types.java:1319)
              at com.sun.tools.javac.code.Types.asOuterSuper(Types.java:1379)
              at com.sun.tools.javac.comp.Attr.checkMethod(Attr.java:2367)
              at com.sun.tools.javac.comp.Attr.visitNewClass(Attr.java:1582)
              at com.sun.tools.javac.tree.JCTree$JCNewClass.accept(JCTree.java:1344)
              at com.sun.tools.javac.comp.Attr.attribTree(Attr.java:394)
              at com.sun.tools.javac.comp.Attr.attribExpr(Attr.java:418)
              at com.sun.tools.javac.comp.Attr.visitExec(Attr.java:1102)
              at com.sun.tools.javac.tree.JCTree$JCExpressionStatement.accept(JCTree.java:1139)
              at com.sun.tools.javac.comp.Attr.attribTree(Attr.java:394)
              at com.sun.tools.javac.comp.Attr.attribStat(Attr.java:438)
              at com.sun.tools.javac.comp.Attr.attribStats(Attr.java:454)
              at com.sun.tools.javac.comp.Attr.visitBlock(Attr.java:800)
              at com.sun.tools.javac.tree.JCTree$JCBlock.accept(JCTree.java:762)
              at com.sun.tools.javac.comp.Attr.attribTree(Attr.java:394)
              at com.sun.tools.javac.comp.Attr.attribStat(Attr.java:438)
              at com.sun.tools.javac.comp.Attr.visitMethodDef(Attr.java:720)
              at com.sun.tools.javac.tree.JCTree$JCMethodDecl.accept(JCTree.java:650)
              at com.sun.tools.javac.comp.Attr.attribTree(Attr.java:394)
              at com.sun.tools.javac.comp.Attr.attribStat(Attr.java:438)
              at com.sun.tools.javac.comp.Attr.attribClassBody(Attr.java:2826)
              at com.sun.tools.javac.comp.Attr.attribClass(Attr.java:2752)
              at com.sun.tools.javac.comp.Attr.attribClass(Attr.java:2688)
              at com.sun.tools.javac.main.JavaCompiler.attribute(JavaCompiler.java:1120)
              at com.sun.tools.javac.main.JavaCompiler.compile2(JavaCompiler.java:846)
              at com.sun.tools.javac.main.JavaCompiler.compile(JavaCompiler.java:808)
              at com.sun.tools.javac.main.Main.compile(Main.java:400)
              at com.sun.tools.javac.main.Main.compile(Main.java:318)
              at com.sun.tools.javac.main.Main.compile(Main.java:309)
              at com.sun.tools.javac.Main.compile(Main.java:82)
              at com.sun.tools.javac.Main.main(Main.java:67)
      Java Result: 4

        Attachments

          Issue Links

            Activity

              People

              • Assignee:
                mcimadamore Maurizio Cimadamore
                Reporter:
                mcimadamore Maurizio Cimadamore
              • Votes:
                0 Vote for this issue
                Watchers:
                0 Start watching this issue

                Dates

                • Created:
                  Updated:
                  Resolved:
                  Imported:
                  Indexed: