@Override must override a superclass method 问题解决

一、问题的由来

最近接手了了一个合作企业的项目,前期不是我司开发的,上周做了几天的技术对接,客户端界面由我负责对接,从svn检出之后,迫不及待的导入到了本地的myeclipse中,谁知立马就出现了那个小红叉,各种找原因,最终得以解决,现将研究过程总结如下:

二、@Override 是JDK5引入的,描述如下: 
Indicates that a method declaration is intended to override a method declaration in a superclass. If a method is annotated with this annotation type but does not override a superclass method, compilers are required to generate an error message. 
 

在JDK6文档中的描述是一模一样!但是真正的麻烦就出在superclass 的理解上!JDK5认为Override重载是覆盖父类方法,而JDK6则将覆盖父类方法与实现接口方法,都定义为Override superclass。 因此只要是实现接口方法的地方写了@Override,JDK5都会报错

 

个人感觉JDK5的@Override可能是设计时候的bug吧:) 因为感觉JDK6的理解比较正确。

 

三、Myeclipse环境下修改@override引发的错误的方法

 

项目右键->build path->configure build path->java Compiler(左边那排中) ->在右边的Compiler compliance level 修改版本为1.6

 

posted @ 2016-03-29 17:05  npe0  阅读(8356)  评论(0编辑  收藏  举报