Bug 81222 - [1.5][compiler] Name clash when extending a raw superclass and overriding a method with parameterized type as parameter type
Summary: [1.5][compiler] Name clash when extending a raw superclass and overriding a m...
Status: VERIFIED INVALID
Alias: None
Product: JDT
Classification: Eclipse Project
Component: Core (show other bugs)
Version: 3.1   Edit
Hardware: PC Windows XP
: P3 minor (vote)
Target Milestone: 3.2 M6   Edit
Assignee: Kent Johnson CLA
QA Contact:
URL:
Whiteboard:
Keywords:
Depends on:
Blocks:
 
Reported: 2004-12-15 11:39 EST by Markus Keller CLA
Modified: 2006-03-27 10:26 EST (History)
1 user (show)

See Also:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Markus Keller CLA 2004-12-15 11:39:09 EST
I20041214-2000

I'm not sure whether this is bug - if so, javac suffers from the same problem.

import java.util.List;

class A<E> {
	public void x(List<String> s) { }
}
class B extends A/*raw!*/ {
	public void x(List<String> s) { }
}

Error message for B#x(..): "Name clash : The method x(List<String>) of type B
has the same erasure as x(List<String>) of type A but does not override it"

I did not find anything in the JLS which would prevent B.x(..) from overriding
A.x(..).
Comment 1 Markus Keller CLA 2005-08-15 12:18:04 EDT
In I20050811-1530, Eclipse does not issue an error any more (javac 1.5.0_04
still errors). In the class files, B#x(..) overrides A#x(..), but the compiler
rejects an @Override annotation on B#x(..), which is inconsistent.

It could be that JLS3 §4.8, p. 59 defines this, but I'm not completely sure:
"The type of a constructor (§8.8), instance method (§8.8, §9.4), or non-static
field (§8.3) M of a raw type C that is not inherited from its superclasses or
superinterfaces is the erasure of its type in the generic declaration
corresponding to C.".

Reading this together with §8.2 (the type of a method is an ordered 3-tuple of
argument types, return type, throws clause) would suggest that the inherited
method from raw A is:
	public void x(List s)

And this method cannot be overridden by
	public void x(List<String> s) { }

Concluding, I'd say eclipse's current behavior is wrong (but used to be correct
at the time I filed the then wrongly accusing bug).
Comment 2 Markus Keller CLA 2005-09-13 13:03:36 EDT
The given example is indeed incorrect and the compiler should raise an error.
See http://bugs.sun.com/bugdatabase/view_bug.do?bug_id=6322564
Comment 3 Kent Johnson CLA 2006-02-22 15:06:37 EST
Added MethodVerify test79
Comment 4 Frederic Fusier CLA 2006-03-27 10:14:11 EST
Reopen to change resolution
Comment 5 Frederic Fusier CLA 2006-03-27 10:15:01 EST
As said in comment 2, comment 0 should fail => close bug as INVALID