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

stack overflow for cyclic class inheritance

    XMLWordPrintable

    Details

    • Subcomponent:
    • CPU:
      sparc
    • OS:
      solaris_2.4

      Description

      The following test causes java.lang.StackOverflowError in
      sun.tools.java.ClassDefinition.getFirstMatch(ClassDefinition.java:122).

      I've tried to make the test less in size but the effect disappeares
      and compiler reports correct message:
      clss005.java:13: Cyclic class inheritance.

      See log below:

      > cat clss005.java
      // Ident: @(#)clss005.java 1.1 96/01/14
      // Copyright 14 Jan 1996 Sun Microsystems, Inc. All Rights Reserved

      class clss005_a {
      int a= 5;
      public int b = a + 1;
      public int c = b + 1;
         public void add(int x) {
         a += x;
         }
      }

      class clss005_b extends clss005_b{
      int a= 50;
      public int b = a + 10;
         public void test() {
         add(a);
         add(b);
         add(c);
         }
      }

      public class clss005 {
        public static void main(String args[]) {
         clss005_b cl_x;
         cl_x.test();
        }
      }


      > /usr/local/java/1.0/bin/javac clss005.java

      java.lang.StackOverflowError
      at sun.tools.java.ClassDefinition.getFirstMatch(ClassDefinition.java:122)
      at sun.tools.java.ClassDefinition.matchMethod(ClassDefinition.java:381)
      at sun.tools.java.ClassDefinition.matchMethod(ClassDefinition.java:410)
      ... repeating 4668 times
      at sun.tools.java.ClassDefinition.matchMethod(ClassDefinition.java:410)
      at sun.tools.java.ClassDefinition.matchMethod(ClassDefinition.java:433)
      at sun.tools.tree.MethodExpression.checkValue(MethodExpression.java:122)
      at sun.tools.tree.MethodExpression.check(MethodExpression.java:209)
      at sun.tools.tree.ExpressionStatement.check(ExpressionStatement.java:43)
      at sun.tools.tree.CompoundStatement.check(CompoundStatement.java:48)
      at sun.tools.tree.Statement.checkMethod(Statement.java:64)
      at sun.tools.javac.SourceField.check(SourceField.java:209)
      at sun.tools.javac.SourceClass.check(SourceClass.java:431)
      at sun.tools.javac.SourceClass.compileClass(SourceClass.java:540)
      at sun.tools.javac.SourceClass.compile(SourceClass.java:527)
      at sun.tools.javac.Main.compile(Main.java:193)
      at sun.tools.javac.Main.main(Main.java:289)
      clss005.java:26: Variable cl_x may not have been initialized.
         cl_x.test();
         ^
      error: An error has occurred in the compiler; please file a bug report (###@###.###).
      2 errors

        Attachments

          Issue Links

            Activity

              People

              Assignee:
              fyellinsunw Frank Yellin (Inactive)
              Reporter:
              leosunw Leo Leo (Inactive)
              Votes:
              0 Vote for this issue
              Watchers:
              0 Start watching this issue

                Dates

                Created:
                Updated:
                Resolved:
                Imported:
                Indexed: