8.1.4: Superclass/superinterface "depends" relationship misses imported qualified names

XMLWordPrintable

      Example below cannot compile due to error "cyclic inheritance involving test.A".

      -------Example----------
      //file A.java
      package test;

      class A extends C {
          static class B {}
      }

      //file C.java
      package test;

      import static test.A.B;

      class C extends B {}
      ------------------------------

      Same error for static-import-on-demand clause and for various combinations of classes and interfaces.
      This behaviour is expected - C depends on A because B is nested in A. But specification says nothing about dependencies via static import.

      This is what specification says about dependencies:

      Section 8.1.4 (http://docs.oracle.com/javase/specs/jls/se8/html/jls-8.html#jls-8.1.4):
      "A class C directly depends on a type T if T is mentioned in the extends or implements clause of C either as a superclass or superinterface, or as a qualifier of a superclass or superinterface name.

      A class C depends on a reference type T if any of the following is true:
       C directly depends on T.
       C directly depends on an interface I that depends (§9.1.3) on T.
       C directly depends on a class D that depends on T (using this definition recursively)."

      Section 9.1.3 (http://docs.oracle.com/javase/specs/jls/se8/html/jls-9.html#jls-9.1.3):
      "An interface I directly depends on a type T if T is mentioned in the extends clause of I either as a superinterface or as a qualifier within a superinterface name.

      An interface I depends on a reference type T if any of the following is true:
       I directly depends on T.
       I directly depends on a class C that depends on T (§8.1.5).
       I directly depends on an interface J that depends on T (using this definition recursively).

      It is a compile-time error if an interface depends on itself."

      Possible solution would be to add cases with static import in "directly depends..." parts (similarly to qualifier cases).

            Assignee:
            Alex Buckley
            Reporter:
            Stanislav Lukyanov (Inactive)
            Votes:
            0 Vote for this issue
            Watchers:
            3 Start watching this issue

              Created:
              Updated:
              Resolved: