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

Peculiar inner class construction generates an infinite length error message.

XMLWordPrintable

    • Icon: Bug Bug
    • Resolution: Not an Issue
    • Icon: P3 P3
    • None
    • 1.1.5, 1.2.0
    • tools
    • x86, sparc
    • solaris_2.6, windows_95, windows_nt


      allan.jacobs@Eng 1998-03-23

      A code in which the inner class C2 possesses an inner class member of
      type C3 that extends C2 is compiled by javac. When executed,
      the constructors for C2 and C3 call one another recursively ad-infinitum.

      algol% cat X.ksh
      #!/bin/ksh
      PATH=/net/exactvm.eng/exactvm/builds/JDK1.2L-build/build/solaris/bin;
      PATH=${PATH}:/usr/dt/bin:/bin:/usr/bin:.:/usr/openwin/bin;
      export PATH;
      unset CLASSPATH;
      java -version;
      uname -a;
      javac -d . X.java;
      java X;
      algol% cat X.java

      /* Derived from Modena test ciner078. */
       
      class X {
              C1 oc1;
              int func1() { return 10; }
              class C1 {
                      C2 oc2;
                      int func1() { return 20; }
                      // This class should possess 3 instances.
       
                      class C2 {
                              C3 c3 = new C3 ();
                              class C3 extends C2 {
                                      int func1() { return 10; }
                              } // end of class C3
                              int func1() { return 30; }
                      } //end class C2
              } //end class C1

              public static void main(String argv[]) {
                      X ox = new X();
                      ox.oc1 = ox.new C1();
                      ox.oc1.oc2 = ox.oc1.new C2(); // This construction runs amok!
              }
      }

      algol% X.ksh
      java version "katleman:03.13.98-09:01"
      SunOS algol 5.6 Generic sun4u sparc SUNW,Ultra-1
      java.lang.StackOverflowError
              at X$C1$C2$C3.<init>(X.java:14)
              at X$C1$C2.<init>(X.java:13)
              at X$C1$C2$C3.<init>(X.java:14)
              at X$C1$C2.<init>(X.java:13)
              at X$C1$C2$C3.<init>(X.java:14)

            wmaddoxsunw William Maddox (Inactive)
            ajacobssunw Allan Jacobs (Inactive)
            Votes:
            0 Vote for this issue
            Watchers:
            0 Start watching this issue

              Created:
              Updated:
              Resolved:
              Imported:
              Indexed: