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

Non-static field in a class extending an inner class is not initialized.

XMLWordPrintable

    • sparc
    • solaris_2.6

      /* Adapted from Modena (v3.0) test ciner034. */
      class A {
          int a = 1;
          class B {
              int b = 2;
              class C {
                  int c = 3;
                  class Y {
                      int i = 4;
                      class D {
                          int j = 5;
                          int k = Y.this.i;
                      }//end of class D
                  }//end of class Y
              }//end of class C
          }//end of class B
      }//end of class A
      class X extends A.B.C.Y.D {
          int x = 6;
          X(A.B.C.Y oy) { oy.super(); }
          public void check_accessibility() {
              if (j!=5)
                  System.out.println("err_1: j="+j+". Expected 5.");
              if (k!=4)
                  System.out.println("err_2: k="+k+". Expected 4.");
              if (x!=6)
                  System.out.println("err_3: x="+x+". Expected 6.");
          }
          public static void main(String argv[]) {
              A.B ab = new A().new B();
              A.B.C abc = ab.new C();
              A.B.C.Y abcy = abc.new Y();
              new X(abcy).check_accessibility();
          }
      }
      algol% /net/mulder.eng/export/mulder3/jdk12x/sparc/jdk1.2.1_I/bin/javac -d . X.java
      algol% /net/mulder.eng/export/mulder3/jdk12x/sparc/jdk1.2.1_I/bin/java X
      err_3: x=0. Expected 6.

      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: