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

Odd inner class code construct causes the compiler to abort.

    XMLWordPrintable

    Details

    • Type: Bug
    • Status: Closed
    • Priority: P4
    • Resolution: Duplicate
    • Affects Version/s: 1.1.6, 1.2.0, 1.2.1, 1.2.2
    • Fix Version/s: None
    • Component/s: tools
    • Subcomponent:
    • CPU:
      generic, x86, sparc
    • OS:
      generic, solaris_2.6, windows_95, windows_nt

      Description

      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

        Attachments

          Issue Links

            Activity

              People

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

                Dates

                Created:
                Updated:
                Resolved:
                Imported:
                Indexed: