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

Stack overflow with anonymous class in super() parameter

XMLWordPrintable

    • Icon: Bug Bug
    • Resolution: Fixed
    • Icon: P4 P4
    • 24
    • 22
    • tools
    • b04
    • generic
    • generic

      Compiling the following source code generates a StackOverflowError:

          public class Test1 {
              class Inner {
                  Inner() {
                      this(() -> new Object() { { Test1.this.hashCode(); } });
                  }
                  Inner(Runnable r) {
                  }
              }
          }

      Verified on JDK 8, 11, 17, 22, and current 24 head.

      $ javac -version
      javac 22
      $ javac Test1.java


      The system is out of resources.
      Consult the following stack trace for details.
      java.lang.StackOverflowError
      at jdk.compiler/com.sun.tools.javac.code.Symbol$ClassSymbol.isSubClass(Symbol.java:1403)
      at jdk.compiler/com.sun.tools.javac.code.Symbol.isMemberOf(Symbol.java:559)
      at jdk.compiler/com.sun.tools.javac.comp.Lower.access(Lower.java:1285)
      at jdk.compiler/com.sun.tools.javac.comp.Lower.access(Lower.java:1344)
      at jdk.compiler/com.sun.tools.javac.comp.Lower.makeOwnerThisN(Lower.java:1905)
      at jdk.compiler/com.sun.tools.javac.comp.Lower.makeOwnerThis(Lower.java:1890)
      at jdk.compiler/com.sun.tools.javac.comp.Lower.accessBase(Lower.java:1135)
      at jdk.compiler/com.sun.tools.javac.comp.Lower.access(Lower.java:1323)
      at jdk.compiler/com.sun.tools.javac.comp.Lower.access(Lower.java:1344)
      at jdk.compiler/com.sun.tools.javac.comp.Lower.makeOwnerThisN(Lower.java:1905)
      at jdk.compiler/com.sun.tools.javac.comp.Lower.makeOwnerThis(Lower.java:1890)
      at jdk.compiler/com.sun.tools.javac.comp.Lower.accessBase(Lower.java:1135)
      at jdk.compiler/com.sun.tools.javac.comp.Lower.access(Lower.java:1323)
      at jdk.compiler/com.sun.tools.javac.comp.Lower.access(Lower.java:1344)
      at jdk.compiler/com.sun.tools.javac.comp.Lower.makeOwnerThisN(Lower.java:1905)
      at jdk.compiler/com.sun.tools.javac.comp.Lower.makeOwnerThis(Lower.java:1890)
      at jdk.compiler/com.sun.tools.javac.comp.Lower.accessBase(Lower.java:1135)
      at jdk.compiler/com.sun.tools.javac.comp.Lower.access(Lower.java:1323)
      at jdk.compiler/com.sun.tools.javac.comp.Lower.access(Lower.java:1344)
      at jdk.compiler/com.sun.tools.javac.comp.Lower.makeOwnerThisN(Lower.java:1905)
      at jdk.compiler/com.sun.tools.javac.comp.Lower.makeOwnerThis(Lower.java:1890)
      at jdk.compiler/com.sun.tools.javac.comp.Lower.accessBase(Lower.java:1135)
      at jdk.compiler/com.sun.tools.javac.comp.Lower.access(Lower.java:1323)
      at jdk.compiler/com.sun.tools.javac.comp.Lower.access(Lower.java:1344)
      at jdk.compiler/com.sun.tools.javac.comp.Lower.makeOwnerThisN(Lower.java:1905)
      at jdk.compiler/com.sun.tools.javac.comp.Lower.makeOwnerThis(Lower.java:1890)
      at jdk.compiler/com.sun.tools.javac.comp.Lower.accessBase(Lower.java:1135)

            mcimadamore Maurizio Cimadamore
            acobbs Archie Cobbs
            Votes:
            0 Vote for this issue
            Watchers:
            4 Start watching this issue

              Created:
              Updated:
              Resolved: