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

invalid scoping for cyclic inner interfaces

XMLWordPrintable

    • sparc
    • solaris_2.5.1




      Name: laC46010 Date: 07/09/97



      Java compiler fails to find inherited inner interface.
      In accordance to evaluation of the Bug Id 4063501, it might be
      concluded, that validity of such way of cyclic inheritance means
      enclosed interface 'B' (see example "Test.java" below, taken
      from that bug) inherits itself from superinterface 'A'. Thus,
      name 'B' should be defined for any instance of type 'B'.
      Moreover, each inherited in this way interface automatically
      inherits name 'B', and so forth to the eternity.

      Besides, indepth understanding of this example reveals that
      interface 'A' has sort of fractal structure. Indeed, complicated
      eternal interface 'A' is inherited by all interfaces on all levels
      of inheritance chain and, again, does contain endless chains of
      this kind, and so on.

      Example "TestNew.java" below shows how such considerations might
      affect accessibility for inherited members. If it is stated that
      such inheritance is not a bug, then we could try to access interface
      'B' inherited by interface 'Test.A.B'.
      However, all JDK compilers from 1.1 thru 1.1.3 deny this and report
      the following compile-time errors for example "TestNew.java":


      a.java:7: No variable B defined in nested interface Test. A.B.
      int k2 = A.B.B.x;
      ^
      a.java:8: No variable B defined in nested interface Test. A.B.
      int k3 = A.B.B.B.B.B.B.B.B.B.B.x;
      ^
      2 errors


      --------------------TestValid.java----------------------
      class Test {
      interface A {
      interface B extends A {}
      }
      }
      --------------------TestNew.java----------------------
      class Test {
      interface A {
      final int x = 153;
      interface B extends A {}
      }
      int k1 = A.B.x;
      int k2 = A.B.B.x;
      int k3 = A.B.B.B.B.B.B.B.B.B.B.x;
      }
      --------------------------------------------------------------------------------

      ======================================================================

            wmaddoxsunw William Maddox (Inactive)
            leosunw Leo Leo (Inactive)
            Votes:
            0 Vote for this issue
            Watchers:
            0 Start watching this issue

              Created:
              Updated:
              Resolved:
              Imported:
              Indexed: