JDK-6424261 : Description of "override" in JLS 3 section 6.4.3 is misleading.
  • Type: Bug
  • Component: specification
  • Sub-Component: language
  • Affected Version: 6
  • Priority: P5
  • Status: Closed
  • Resolution: Fixed
  • OS: generic
  • CPU: generic
  • Submitted: 2006-05-10
  • Updated: 2014-02-26
  • Resolved: 2011-07-21
The Version table provides details related to the release that this issue/RFE will be addressed.

Unresolved : Release in which this issue/RFE will be addressed.
Resolved: Release in which this issue/RFE has been resolved.
Fixed : Release in which this issue/RFE has been fixed. The release containing this fix may be available for download as an Early Access Release or a General Availability Release.

To download the current JDK release, click here.
JDK 7
7 rcFixed
Related Reports
Relates :  
Relates :  
Relates :  
Description
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.

Comments
EVALUATION Peter's blog: http://blogs.sun.com/ahe/entry/override
07-12-2006

EVALUATION 6.4.3 will say: If the method not inherited is abstract and the new declaration is abstract, or the method not inherited is declared in a class, then the new declaration is said to override it. If the method not inherited is abstract and the new declaration is not abstract, then the new declaration is said to implement it. 1) The spec should reflect Peter's blog example: interface A { void m(); } class B implements A { public void m() {} } // Logically: Implements, does not override // Old 6.4.3: Implements, says nothing about overriding // New 6.4.3: Implements, says nothing about overriding // 8.4.8.1: Says nothing - There is no overriding in 1), either logically or in the spec. 2) 8.4.8.1 is sacrosanct (re: Eval in 6409362). Thus: abstract class C { abstract void m(); } class D extends C { void m() {...} } // Logically: Implements, does not override (as if C was an interface) // Old 6.4.3: Implements, says nothing about overriding // New 6.4.3: Overrides, implements // 8.4.8.1: Overrides, implements - There is overriding in 2) because 8.4.8.1 says so. This is illogical, since abstract class C is analogous to an interface, implying implementing not overriding. But 8.4.8.1 is not going to change, and 6.4.3 should be consistent with it. 3) Scott contributes this example: abstract class C { abstract void m(); } abstract class D extends C { abstract void m(); } // Logically: Overrides, does not implement (as if C and D were interfaces) // Old 6.4.3: Implements, says nothing about overriding // New 6.4.3: Overrides, says nothing about implementing // 8.4.8.1: Overrides, does not implement 4) Scott also contributes this example: interface C { void m(); } abstract class D implements C { public abstract void m(); } // Logically: Overrides, does not implement (same as if D was an interface) // Old 6.4.3: Implements, says nothing about overriding // New 6.4.3: Overrides, says nothing about implementing // 8.4.8.1: Says nothing - 3) and 4) show an improvement for the new 6.4.3 over the old 6.4.3. 5) Also: class C { void m() {} } abstract class D extends C { abstract void m(); } // Logically: Overrides, does not implement // Old 6.4.3: Overrides, says nothing about implementing // New 6.4.3: Overrides, says nothing about implementing // 8.4.8.1: Overrides, does not implement
07-12-2006