在Eclipse中覆盖注释的Bug [英] Bug with Override annotations in Eclipse

查看:196
本文介绍了在Eclipse中覆盖注释的Bug的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在Eclipse中的 @Override 注释中有一个令人讨厌的问题。通常,当我在一台新的电脑上导入工作项目时,Eclipse将某些 @Override 注释标记为错误。如果我删除注释,一切都很好,Eclipse也表示方法覆盖了父方法,但是添加覆盖注释会再次导致错误。我目前正在研究一个Android项目,所以这可能是Android的问题,而不是Eclipse。

I have a annoying problem with @Override annotations in Eclipse. Often when i import working projects on a new PC, Eclipse marks some of the @Override annotations as wrong. If i remove the annotations everything is fine and Eclipse also indicates that the methods are overriding the parents methods but adding the Override annotation causes the error again. I am currently working on an Android project so it might be a problem with Android and not with Eclipse..

推荐答案

这是最多的可能是因为您在Java 1.5和Java 1.6之间进行切换。在1.5中,您无法使用@Override标记接口实现,但可以在1.6中。

This is most likely because you are switching between Java 1.5 and Java 1.6. In 1.5 you couldn't mark interface implementations with @Override, but you can in 1.6.

一个快速的Google搜索可以很好地解释这个注释之间的区别两个版本: http://www.techienuggets.com/CommentDetail?tx=38155

A quick Google search turned up this good explanation of the difference in this annotation between the two versions: http://www.techienuggets.com/CommentDetail?tx=38155



JDK 1.5和JDK 1.6中的@Override的语义不同。在JDK 1.5中,不允许
@Override注释
用于在接口中声明的方法
的实现,而在JDK 1.6中允许
。有关更多
信息,请参阅:

Semantics of @Override is different in JDK 1.5 and JDK 1.6. In JDK 1.5, the @Override annotation is not allowed for implementations of methods declared in an interface, while they are allowed in JDK 1.6. For more information, see:

http://bugs.sun.com/bugdatabase/view_bug.do?bug_id=5008260
http://bugs.sun.com/bugdatabase/view_bug.do?bug_id=6399361
http://blogs.oracle.com/ahe/?entry=override

事实上,JDK API文档中
覆盖注释的描述未更新
。这是
报告为一个错误:

It is fact that the description of the Override annotation was not updated in the JDK API docs. This has been reported as a bug:

http://bugs.sun.com/bugdatabase/view_bug.do?bug_id=6501053bugdatabase/view_bug.do?bug_id=6501053

这篇关于在Eclipse中覆盖注释的Bug的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆