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

[local-methods] Javac crashes compiling a method local to an initializer block

    Details

    • Type: Bug
    • Status: Resolved
    • Priority: P4
    • Resolution: Fixed
    • Affects Version/s: repo-amber
    • Fix Version/s: repo-amber
    • Component/s: tools
    • Labels:
    • Subcomponent:
    • CPU:
      generic
    • OS:
      generic

      Description

      Compiling this code:

      public class X {
          {
              void foo() {
                  System.out.println("foo in init block");
              }
              foo();
          }
       
          public static void main(String [] args) {
              new X();
          }
      }

      results in:

      An exception has occurred in the compiler (14-internal). 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, the following diagnostic, and the parameters passed to the Java compiler in your report. Thank you.
      java.lang.NullPointerException
      at jdk.compiler/com.sun.tools.javac.code.Symbol$MethodSymbol.<init>(Symbol.java:1732)
      at jdk.compiler/com.sun.tools.javac.comp.MemberEnter.visitMethodDef(MemberEnter.java:183)
      at jdk.compiler/com.sun.tools.javac.tree.JCTree$JCMethodDecl.accept(JCTree.java:876)
      at jdk.compiler/com.sun.tools.javac.comp.MemberEnter.memberEnter(MemberEnter.java:163)
      at jdk.compiler/com.sun.tools.javac.comp.Attr.visitMethodDef(Attr.java:977)
      at jdk.compiler/com.sun.tools.javac.tree.JCTree$JCMethodDecl.accept(JCTree.java:876)
      at jdk.compiler/com.sun.tools.javac.comp.Attr.attribTree(Attr.java:666)
      at jdk.compiler/com.sun.tools.javac.comp.Attr.attribStat(Attr.java:738)
      at jdk.compiler/com.sun.tools.javac.comp.Attr.attribStats(Attr.java:756)
      at jdk.compiler/com.sun.tools.javac.comp.Attr.visitBlock(Attr.java:1299)
      at jdk.compiler/com.sun.tools.javac.tree.JCTree$JCBlock.accept(JCTree.java:1030)
      at jdk.compiler/com.sun.tools.javac.comp.Attr.attribTree(Attr.java:666)
      at jdk.compiler/com.sun.tools.javac.comp.Attr.attribStat(Attr.java:738)
      at jdk.compiler/com.sun.tools.javac.comp.Attr.attribClassBody(Attr.java:4861)
      at jdk.compiler/com.sun.tools.javac.comp.Attr.attribClass(Attr.java:4752)
      at jdk.compiler/com.sun.tools.javac.comp.Attr.attribClass(Attr.java:4681)
      at jdk.compiler/com.sun.tools.javac.comp.Attr.attrib(Attr.java:4626)
      at jdk.compiler/com.sun.tools.javac.main.JavaCompiler.attribute(JavaCompiler.java:1346)
      at jdk.compiler/com.sun.tools.javac.main.JavaCompiler.compile(JavaCompiler.java:972)
      at jdk.compiler/com.sun.tools.javac.main.Main.compile(Main.java:318)
      at jdk.compiler/com.sun.tools.javac.main.Main.compile(Main.java:176)
      at jdk.compiler/com.sun.tools.javac.Main.compile(Main.java:57)
      at jdk.compiler/com.sun.tools.javac.Main.main(Main.java:43)
      at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
      at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
      at java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
      at java.base/java.lang.reflect.Method.invoke(Method.java:564)
      at com.intellij.rt.execution.application.AppMainV2.main(AppMainV2.java:131)

        Attachments

          Activity

            People

            • Assignee:
              sadayapalam Srikanth Adayapalam
              Reporter:
              sadayapalam Srikanth Adayapalam
            • Votes:
              0 Vote for this issue
              Watchers:
              1 Start watching this issue

              Dates

              • Created:
                Updated:
                Resolved: