错误在Eclipse中覆盖注解 [英] Bug with Override annotations in Eclipse

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

问题描述

我有一个恼人的问题与 @覆盖注释在Eclipse中。通常当我输入一个新的PC机上的工作项目时,Eclipse标志着一些 @覆盖注解错误的。如果我删除批注一切都很好,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.

一个快速谷歌搜索变成了两个版本之间的这种标注的区别就是很好的说明:<一href="http://www.techienuggets.com/CommentDetail?tx=38155">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。在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:

<一个href="http://bugs.sun.com/bugdatabase/view_bug.do?bug_id=5008260">http://bugs.sun.com/bugdatabase/view_bug.do?bug_id=5008260   http://bugs.sun.com/bugdatabase/view_bug.do?bug_id=6399361   <一href="http://blogs.oracle.com/ahe/?entry=override">http://blogs.oracle.com/ahe/?entry=override

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:

<一个href="http://bugs.sun.com/bugdatabase/view_bug.do?bug_id=6501053bugdatabase/view_bug.do?bug_id=6501053">http://bugs.sun.com/bugdatabase/view_bug.do?bug_id=6501053bugdatabase/view_bug.do?bug_id=6501053

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

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