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

Odd inner class code construct causes the compiler to abort.

XMLWordPrintable

    • Icon: Bug Bug
    • Resolution: Duplicate
    • Icon: P4 P4
    • None
    • 1.1.6, 1.2.0, 1.2.1, 1.2.2
    • tools
    • generic, x86, sparc
    • generic, solaris_2.6, windows_95, windows_nt

      algol% cat X.java

      /* Adapted from Modena (v3.0) test ciner113 */
      class X {
        static Y oy;
        static void f() { oy = new Y(); }
        static class Y {
          Z oz = new Z();
          static class Z {
            T ot =new T();
            static class T {
              int i = 10;
              public void f() {
                if (this.i!=i) System.out.println(
                "err_2: i="+this.i+" Expected "+i);
              }
            }
          }
        }
        static public void main(String a[]) {
          try { new X().new Y().oz.ot.f(); }
          catch (Exception e) { new X().new Y().oz.ot.f(); }
          finally { f(); new X().oy.oz.ot.f(); }
        }
      }

      The result of using JDK1.2.1_I javac to compile X.java is attached. The jit
      was disabled, so there are line numbers in the traceback.

      Altering, X.java so that the static inner class Y is not constructed with
      an enclosing instance makes the problem go away. I don't see why the
      construct "new X().new Y()" is even allowed. In any case, Y.java compiles
      fine.

      algol% cat Y.java

      /* Adapted from Modena (v3.0) test ciner113 */
      class X {
        static Y oy;
        static void f() { oy = new Y(); }
        static class Y {
          Z oz = new Z();
          static class Z {
            T ot =new T();
            static class T {
              int i = 10;
              public void f() {
                if (this.i!=i) System.out.println(
                "err_2: i="+this.i+" Expected "+i);
              }
            }
          }
        }
        static public void main(String a[]) {
          try { new Y().oz.ot.f(); }
          catch (Exception e) { new Y().oz.ot.f(); }
          finally { f(); oy.oz.ot.f(); }
        }
      }

      allan.jacobs@Eng 1999-03-29

            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: