Javac stack overflow on method-local class with nested record referring to enclosing type

XMLWordPrintable

    • Type: Bug
    • Resolution: Unresolved
    • Priority: P4
    • None
    • Affects Version/s: 25
    • Component/s: tools
    • None

      The following code causes a stack overflow:

      ```
          class CrashTest {
              public void methodLocalClass() {
                  class Local {
                      private CrashTest owner;
                      private int i;

                      Local(CrashTest owner, int i) {
                          this.owner = owner;
                          this.i = i;
                      }

                      record V1(CrashTest owner, int i) {
                          public Local unmarshal() {
                              return new Local(owner, i);
                          }
                      }
                  }
              }
          }
      ```

      Truncated output:

      ```
      An exception has occurred in the compiler (27-internal). Please file a bug against the Java compiler via the Java bug reporting page (https://bugreport.java.com) after checking the Bug Database (https://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.StackOverflowError
      at jdk.compiler/com.sun.tools.javac.code.Symbol$ClassSymbol.flags(Symbol.java:1388)
      at jdk.compiler/com.sun.tools.javac.code.Symbol$ClassSymbol.isSubClass(Symbol.java:1454)
      at jdk.compiler/com.sun.tools.javac.code.Symbol.isMemberOf(Symbol.java:576)
      at jdk.compiler/com.sun.tools.javac.comp.Lower.makeOwnerThis(Lower.java:1745)
      at jdk.compiler/com.sun.tools.javac.comp.Lower.accessBase(Lower.java:1005)
      at jdk.compiler/com.sun.tools.javac.comp.Lower.access(Lower.java:1189)
      at jdk.compiler/com.sun.tools.javac.comp.Lower.access(Lower.java:1202)
      at jdk.compiler/com.sun.tools.javac.comp.Lower.makeOwnerThisN(Lower.java:1766)
      at jdk.compiler/com.sun.tools.javac.comp.Lower.makeOwnerThis(Lower.java:1751)
      at jdk.compiler/com.sun.tools.javac.comp.Lower.accessBase(Lower.java:1005)
      at jdk.compiler/com.sun.tools.javac.comp.Lower.access(Lower.java:1189)
      at jdk.compiler/com.sun.tools.javac.comp.Lower.access(Lower.java:1202)
      at jdk.compiler/com.sun.tools.javac.comp.Lower.makeOwnerThisN(Lower.java:1766)
      at jdk.compiler/com.sun.tools.javac.comp.Lower.makeOwnerThis(Lower.java:1751)
      [...]
      at jdk.compiler/com.sun.tools.javac.comp.Lower.access(Lower.java:1189)
      at jdk.compiler/com.sun.tools.javac.comp.Lower.access(Lower.java:1202)
      at jdk.compiler/com.sun.tools.javac.comp.Lower.makeOwnerThisN(Lower.java:1766)
      at jdk.compiler/com.sun.tools.javac.comp.Lower.makeOwnerThis(Lower.java:1751)
      error: compilation failed
      ```

            Assignee:
            Unassigned
            Reporter:
            Viktor Klang
            Votes:
            0 Vote for this issue
            Watchers:
            1 Start watching this issue

              Created:
              Updated: