[quote="lifethinker"]关键是两者的编译器实现不同。上面的程序可以直接在命令行用javac编译通过,所以我估计jdeveloper使用的编译器就是javac。我以前也一直认为eclipse也是直接使用javac编译器,刚才查看了eclipse插件目录下org.eclipse.jdt.core.jar,里面包括词法分析器,语法解析器,编译器,我才确定eclipse使用了自己的编译器。至于netbeans没有研究,应该也是使用了自己的编译器。
p.s. 在Eclipse下如果接口I中不带任何方法或者方法签名中不使用泛型,则不会出错误。
to feng_gladys:从eclipse提示的错误:
Name clash: The method query(Map, int) of type C has the same erasure as query(Map, int) of type I but does not override it
这样解释也合乎情理,但是从语言规范上来说应该是容许这种情况发生的,不应该有任何错误,至多也只是警告,不过提示错误也未尝不是坏事。
[/quote]
以下这段话是 The Java Programming Language 中描述overridding的:
A method in a subtype potentially overrides an accessible method in a super type if the two methods have the same name and have override-equivalent signatures. We say "potentially overrides" because there is an additional requirement to be met: The signature of the subclass method must be the same as that of the superclass method, or it must be the same as the erasure of the signature of the superclass method. This constraint makes overriding a "one-way street": [b]A method without generic types can override a method with generic types, but not the other way around[/b].