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

Description of "override" in JLS 3 section 6.4.3 is misleading.

XMLWordPrintable

    • Icon: Bug Bug
    • Resolution: Fixed
    • Icon: P5 P5
    • 7
    • 6
    • specification
    • None
    • rc
    • generic
    • generic
    • Verified

      The formal definition of "overrides" in 8.4.8 does not
      depend on the "abstract" modifier. Abstract comes into play only in that:

        Moreover, if m1 is not abstract, then m1 is said to *implement* any and
        all declarations of abstract methods that it overrides.

      However, there's a less formal description of "overrides" in 6.4.3
      that says:

        If the method not inherited is abstract, then the new declaration is
        said to *implement* it; if the method not inherited is not abstract,
        then the new declaration is said to *override* it.

      The submitter of 6409362 took the latter section at
      face value and incorrectly concluded that "implements" and "overrides"
      are mutually exclusive.
      While discussing this with Peter we noted that:

      Section 8.4.8.1 describes overriding when one class extends another
      class, and section 9.4.1 describes overriding when one interface
      extends another interface. We could not find a similarly-rigorous
      description covering the case of a class implementing an interface:

      interface I { void m(); }
      class C implements I { public void m() {}; }

      The first paragraph of 8.4.8 does, however, seem to imply that 8.4.8.1
      should be applicable, and that since I.m is not inherited by C
      (it's not, right?), it must be due to I.m being overridden by C.m.

            abuckley Alex Buckley
            sseligmasunw Scott Seligman (Inactive)
            Votes:
            0 Vote for this issue
            Watchers:
            0 Start watching this issue

              Created:
              Updated:
              Resolved:
              Imported:
              Indexed: