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

fp.bugs 3581 bad compiler StackOverflowError in getClassDefinition

    XMLWordPrintable

    Details

    • Subcomponent:
    • Resolved In Build:
      1.1
    • CPU:
      sparc
    • OS:
      solaris_2.4, solaris_2.5
    • Verification:
      Not verified

      Description

      Trust me, you will want to redirect all compiler output ( >& outfile ) when you javac this file!
      >From: "D'Arcy Smith" <###@###.###>
      This does not look like form output to me.


      This is a multi-part message in MIME format.

      --------------F8C4D316086
      Content-Type: text/plain; charset=us-ascii
      Content-Transfer-Encoding: 7bit

      Hi,

      I'm using Windoze '95 & JDK 1.0 the attached code realy screws up javac!

      ..darcy

      --
         D'Arcy Smith, Systems Analyst
         Applied Research in Computer Systems (ARCS) Laboratory
         British Columbia Institute of Technology (BCIT), Burnaby, BC, Canada
         E-Mail: ###@###.### URL http://www.arcs.bcit.bc.ca
         Tel: (604) 432-8281 Fax: (604) 436-1297

      --------------F8C4D316086
      Content-Type: text/plain; charset=us-ascii
      Content-Transfer-Encoding: 7bit
      Content-Disposition: inline; filename="Test.java"

      interface BaseInterface
      {
      }

      interface DerivedInterface
         extends DerivedInterface
      {
      }


      class BaseClass
      {
      }


      class DerivedClass1
         extends BaseClass
         implements BaseInterface
      {
      }

      class DerivedClass2
         extends BaseClass
         implements DerivedInterface
      {
      }


      public class Test
      {
         public static void main(String argv[])
         {
            BaseClass b = new BaseClass();
            DerivedClass1 d1 = new DerivedClass1();
            DerivedClass2 d2 = new DerivedClass2();

            System.out.println(b instanceof BaseClass)
            System.out.println(d1 instanceof DerivedClass1)
            System.out.println(d2 instanceof DerivedClass2)
            System.out.println(d1 instanceof BaseClass)
            System.out.println(d2 instanceof BaseClass)
         }
      }

      --------------F8C4D316086--

      The description field as copied from bug report 1239553 follows:

      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:
              bhagen Benjamin Hagen (Inactive)
              Votes:
              0 Vote for this issue
              Watchers:
              0 Start watching this issue

                Dates

                Created:
                Updated:
                Resolved:
                Imported:
                Indexed: