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

Alike methods in interfaces (Inheritance and Overriding)

    Details

    • Subcomponent:
    • Resolved In Build:
      b120
    • CPU:
      generic
    • OS:
      generic
    • Verification:
      Verified

      Backports

        Description

        The following code should be rejected by javac:

        class Param<T> {}
        interface A { void f(Param<String> ls); }
        interface B extends A { void f(Param<Integer> li); }

        JLS 9.4.1 Inheritance and Overriding:
        --
        It is a compile time error if a type declaration T has a member method m1 and there exists a method m2 declared in T or a supertype of T such that all of the following conditions hold:

        * m1 and m2 have the same name.
        * m2 is accessible from T.
        * The signature of m1 is not a subsignature (§8.4.2) of the signature of m2.
        * m1 or some method m1 overrides (directly or indirectly) has the same erasure as m2 or some method m2 overrides (directly or indirectly).
        --

        Thus, interface B should generate a compile-time error:

        - B.f and A.f have the same name
        - A.f is accessible from B
        - The signature of B.f is not a subsignature of A.f
        - B.f has the same erasure as A.f

          Attachments

            Issue Links

              Activity

                People

                • Assignee:
                  mcimadamore Maurizio Cimadamore
                  Reporter:
                  vrudomet Victor Rudometov
                • Votes:
                  0 Vote for this issue
                  Watchers:
                  0 Start watching this issue

                  Dates

                  • Created:
                    Updated:
                    Resolved:
                    Imported:
                    Indexed: