Differences between JDK 1.5 1.6 override and jdkoverride

Source: Internet
Author: User

Differences between JDK 1.5 1.6 override and jdkoverride

An error is reported for some projects during the update today.

After searching online, according to the online description, a batch of configuration changes will not work:

Http://bestchenwu.iteye.com/blog/997420 (method 2 in this, that is, the method I use later)

Http://blog.csdn.net/allenlinrui/article/details/5568817

Http://blog.sina.com.cn/s/blog_6419bc670100i6hc.html

Http://chen2337.blog.163.com/blog/static/34039920201041311718394/

Finally, I asked my colleague, he said he could modify the complier directly,

After 1.5 is changed to 1.6, it is okay to compile again. In Preferences, set Compiler for all projects. All project exceptions are solved:

To sum up the reasons:

The keyword override is in 1.5.It can only be used for class inheritance and cannot be used for interface implementation,It should be said that it is a 1.5 bug,If it is a class inheritance, the method can be added or not added before, and the JVM will be overwritten by default during compilation.(Added to Eclipse by default );But if it is the implementation of the interface, that is, only the method declaration, no method body, this annotation cannot be added before the method. Once this annotation is added, the compiler will report an error during compilation, as described in

However, this problem is fixed in 1.6, that is, it can be used for interface implementation or class inheritance. Therefore, in 1.6, when an interface is inherited or implementedBoth adding or not adding @ Override are considered as rewriting by default, and Eclipse will add

@ Override, as described in

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.