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

Error when inherited methods are override-equivalent

XMLWordPrintable

    • Icon: Bug Bug
    • Resolution: Unresolved
    • Icon: P4 P4
    • tbd
    • 7u45, 8
    • tools

      JLS 7 allows an inherited concrete method of a superclass to "override" an inherited interface method with an override-equivalent signature (8.4.8.4). This is the case _even if_ the concrete signature is not a subsignature of the interface signature; a special unchecked warning is supposed to occur.

      JLS 8 cleans up overriding by preventing the inheritance of overridden methods, but always requiring that the overrider have a subsignature of the overridden method (8.4.8.1).

      javac (7 and 8) follows neither of these, simply inheriting both methods and allowing them to coexist.

      class C<T> { void m(T arg) {} }
      interface I { void m(Class arg); }

      class D extends C<Class<String>> implements I {}
      // expected (7): "overriding" occurs
      // expected (8): error -- conflicting inherited methods
      // actual: error -- abstract method not overridden

      abstract class E extends C<Class<String>> implements I {}
      // expected (7): "overriding" occurs
      // expected (8): error -- conflicting inherited methods
      // actual: no error, but no bridge method

      Since the JLS 7 feature is strange (perhaps motivated by extra migration compatibility?) and was never implemented, it doesn't make much sense to implement it now. It could be treated as a JLS 7 spec bug ("fixed" by the changes in 8). But the JLS 8 behavior should be implemented correctly.

            vromero Vicente Arturo Romero Zaldivar
            dlsmith Dan Smith
            Votes:
            0 Vote for this issue
            Watchers:
            2 Start watching this issue

              Created:
              Updated: