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

javac compiler creates stack overflow on cyclic class inheritance

    • x86
    • windows_95, windows_nt



      Name: dbT83986 Date: 05/01/99


      I accidently stumbled across the following obscure bug using
      JDK1.1.7B javac on Win95 and NT. I do not think it requires a high priority fix :-)
      But it might be useful to have it logged for anyone that gets into a similar situation.
      The annoying thing is that when it happens you get an enormous output
      from the javac compiler. This is similar to bug 4026931

      Jeroen
      =========== start code ==============
      package foo;
      public class bar extends bar implements foobar {
          
      }
      =============== end code =============
      The above(faulty) code produces as expected:
      ============= start output ===========
      D:\workingdir>javac foo\bar.java
      foo\bar.java:2: Cyclic class inheritance.
      public class bar extends bar implements foobar {
                               ^
      1 error
      ============= end output =============
      but the next code:
      =========== start code ==============
      package foo;
      public class bar extends bar implements bar.foobar {
          
      }
      =============== end code =============
      produces:
      ============= start output ===========
      D:\workingdir>javac foo\bar.java
      java.lang.StackOverflowError
              at sun.tools.java.ClassDefinition.getFirstMatch(Compiled Code)
              at sun.tools.java.ClassDefinition.getInnerClass(Compiled Code)
      .... (100's of times deleted)
              at sun.tools.java.ClassDefinition.getInnerClass(Compiled Code)
              at sun.tools.java.ClassDefinition.resolveName(Compiled Code)
              at sun.tools.java.ClassDefinition.resolveName(Compiled Code)
              at sun.tools.java.Environment.resolveNames(Compiled Code)
              at sun.tools.javac.SourceField.resolveTypeStructure(Compiled Code)
              at sun.tools.javac.SourceClass.resolveTypeStructure(Compiled Code)
              at sun.tools.javac.SourceClass.basicCheck(Compiled Code)
              at sun.tools.java.ClassDeclaration.getClassDefinition(Compiled Code)
              at sun.tools.java.ClassDefinition.getInnerClass(Compiled Code)
              at sun.tools.java.ClassDefinition.resolveName(Compiled Code)
              at sun.tools.java.ClassDefinition.resolveName(Compiled Code)
              at sun.tools.java.Environment.resolveNames(Compiled Code)
              at sun.tools.javac.SourceField.resolveTypeStructure(Compiled Code)
              at sun.tools.javac.SourceClass.resolveTypeStructure(Compiled Code)
              at sun.tools.javac.SourceClass.basicCheck(Compiled Code)
              at sun.tools.java.ClassDeclaration.getClassDefinition(Compiled Code)
              at sun.tools.java.ClassDefinition.getInnerClass(Compiled Code)
              at sun.tools.java.ClassDefinition.resolveName(Compiled Code)
              at sun.tools.java.ClassDefinition.resolveName(Compiled Code)
              at sun.tools.java.Environment.resolveNames(Compiled Code)
              at sun.tools.javac.SourceField.resolveTypeStructure(Compiled Code)
              at sun.tools.javac.SourceClass.resolveTypeStructure(Compiled Code)
              at sun.tools.javac.SourceClass.basicCheck(Compiled Code)
              at sun.tools.java.ClassDeclaration.getClassDefinition(Compiled Code)
              at sun.tools.javac.Main.compile(Compiled Code)
              at sun.tools.javac.Main.main(Main.java:465)
      error: An error has occurred in the compiler; please file a bug report (http://j
      ava.sun.com/cgi-bin/bugreport.cgi).
      1 error

      D:\workingdir>
      =============== end output =============
      (Review ID: 57723)
      ======================================================================

      Name: krT82822 Date: 06/04/99


      The following program contains a cyclic class inheritance error.
      This error was detected using the Solaris version of javac 1.1.7.
      The Win32 version of javac 1.1.7B and 1.1.8 could not detect the
      error--the compiler goes into an infinite loop.

      /**
       * Cyclic Inheritance--error found by Solaris version of JDK but not by
       * Win32 version.
       */
      public class CyclicInheritance extends CyclicInheritance {
        public static void main(String args[]) {
        }//main

      }

      Exact text of error messages:
      -----------------------------
      Win32 version:
      javac -classpath classes.zip CyclicInheritance.java
      java.lang.StackOverflowError
      at sun.tools.java.ClassDefinition.getFirstMatch(Compiled Code)
      at sun.tools.java.ClassDefinition.getInnerClass(Compiled Code)
      at sun.tools.java.ClassDefinition.getInnerClass(Compiled Code)
      at sun.tools.java.ClassDefinition.getInnerClass(Compiled Code)
      at sun.tools.java.ClassDefinition.getInnerClass(Compiled Code)
      at sun.tools.java.ClassDefinition.getInnerClass(Compiled Code)
      at sun.tools.java.ClassDefinition.getInnerClass(Compiled Code)
      at sun.tools.java.ClassDefinition.getInnerClass(Compiled Code)
      at sun.tools.java.ClassDefinition.getInnerClass(Compiled Code)
                 (Above line was repeated indefinitely)

      Solaris version:

      javac CyclicInheritance.java
      CyclicInheritance.java:5: Cyclic class inheritance.
      public class CyclicInheritance extends CyclicInheritance {

      1 error

      Version information
      --------------------
      Win32(note: the error occurs in both 1.1.7B and 1.1.8)

      >java -version
      java version "1.1.8"
      >java -fullversion
      java full version "JDK1.1.8M"

      Solaris

      >java -version
      java version "1.1.7"
      >java -fullversion "Solaris_JDK_1.1.7_08"
      (Review ID: 83955)
      ======================================================================

            wmaddoxsunw William Maddox (Inactive)
            dblairsunw Dave Blair (Inactive)
            Votes:
            0 Vote for this issue
            Watchers:
            0 Start watching this issue

              Created:
              Updated:
              Resolved:
              Imported:
              Indexed: