• <tfoot id='fUVym'></tfoot>

    1. <i id='fUVym'><tr id='fUVym'><dt id='fUVym'><q id='fUVym'><span id='fUVym'><b id='fUVym'><form id='fUVym'><ins id='fUVym'></ins><ul id='fUVym'></ul><sub id='fUVym'></sub></form><legend id='fUVym'></legend><bdo id='fUVym'><pre id='fUVym'><center id='fUVym'></center></pre></bdo></b><th id='fUVym'></th></span></q></dt></tr></i><div id='fUVym'><tfoot id='fUVym'></tfoot><dl id='fUVym'><fieldset id='fUVym'></fieldset></dl></div>

      <small id='fUVym'></small><noframes id='fUVym'>

        • <bdo id='fUVym'></bdo><ul id='fUVym'></ul>

        <legend id='fUVym'><style id='fUVym'><dir id='fUVym'><q id='fUVym'></q></dir></style></legend>
      1. 为什么javac在@Override注释上失败

        时间:2023-07-26

              <bdo id='spcd9'></bdo><ul id='spcd9'></ul>

              <legend id='spcd9'><style id='spcd9'><dir id='spcd9'><q id='spcd9'></q></dir></style></legend>

              1. <small id='spcd9'></small><noframes id='spcd9'>

                <tfoot id='spcd9'></tfoot>
                <i id='spcd9'><tr id='spcd9'><dt id='spcd9'><q id='spcd9'><span id='spcd9'><b id='spcd9'><form id='spcd9'><ins id='spcd9'></ins><ul id='spcd9'></ul><sub id='spcd9'></sub></form><legend id='spcd9'></legend><bdo id='spcd9'><pre id='spcd9'><center id='spcd9'></center></pre></bdo></b><th id='spcd9'></th></span></q></dt></tr></i><div id='spcd9'><tfoot id='spcd9'></tfoot><dl id='spcd9'><fieldset id='spcd9'></fieldset></dl></div>

                    <tbody id='spcd9'></tbody>
                  本文介绍了为什么javac在@Override注释上失败的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

                  问题描述

                  当我实现接口的方法时,Eclipse 正在添加 @Override 注释.Eclipse 似乎对此没有任何问题.而我们来自 Cruise Control 的自动化构建过程似乎对此没有任何问题.但是当我从命令行构建时,ant 运行 javac,我得到了这个错误:

                  Eclipse is adding @Override annotations when I implement methods of an interface. Eclipse seems to have no problem with this. And our automated build process from Cruise Control seems to have no problem with this. But when I build from the command-line, with ant running javac, I get this error:

                  [javac] C:pathprojectsrccomusMyClass.java:70: method does not override a method from its superclass
                  [javac]     @Override
                  [javac]      ^
                  [javac] 1 error
                  

                  Eclipse 在 Java 1.6 下运行.Cruise Control 正在运行 Java 1.5.无论我使用哪个版本的 Java,我的 ant 构建都会失败.

                  Eclipse is running under Java 1.6. Cruise Control is running Java 1.5. My ant build fails regardless of which version of Java I use.

                  推荐答案

                  @Override 注释规范在 Java 1.6 中发生了变化.在 Java 1.5 中,编译器不允许在实现的接口方法上使用 @Override 注释,但在 1.6 中却允许.我找到的第一个搜索结果是 博客文章..没有很好的文档记录,但它确实发生了变化.

                  The @Override annotation spec changed in Java 1.6. In Java 1.5, the compiler did not allow the @Override annotation on implemented interface methods, but in 1.6 it does. First search result I found is a blog post here.. It was not well documented, but it did change.

                  Eclipse 正在添加它,因为您的 Eclipse 设置为符合 1.6.您应该尝试将您的构建和 Eclipse 环境保持在相同版本的 Java 上.我不清楚您指定 Cruise Control 是否正在运行 Java 5 是否使用单独的 JDK6 进行编译.

                  Eclipse is adding it because your Eclipse is set for 1.6 compliance. You should try to keep your build and eclipse environments on the same version of Java. It's unclear to me by your specifying Cruise Control is running Java 5 on whether or not it is compiling using a separate JDK6 or not.

                  与上面的1.5 vs 1.6 @Override注解规则分开,记住Eclipse有自己的编译器实现(不是javac),偶尔会有不同的行为.每当某些东西在 Eclipse 中编译,而不是在 Ant 或 Maven 中编译时,您都需要找到一种方法让两个编译器都满意.

                  Separate from the above 1.5 vs 1.6 @Override annotation rules, remember that Eclipse has its own compiler implementation (not javac) and will occasionally have different behavior. Whenever something compiles in Eclipse, but not Ant or Maven, you will need to find a way to make both compilers happy.

                  这篇关于为什么javac在@Override注释上失败的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持html5模板网!

                  上一篇:为什么 Eclipse 在接口方法上抱怨 @Override? 下一篇:为什么缺少注释不会在运行时导致 ClassNotFoundEx

                  相关文章

                  最新文章

                1. <i id='2O8W1'><tr id='2O8W1'><dt id='2O8W1'><q id='2O8W1'><span id='2O8W1'><b id='2O8W1'><form id='2O8W1'><ins id='2O8W1'></ins><ul id='2O8W1'></ul><sub id='2O8W1'></sub></form><legend id='2O8W1'></legend><bdo id='2O8W1'><pre id='2O8W1'><center id='2O8W1'></center></pre></bdo></b><th id='2O8W1'></th></span></q></dt></tr></i><div id='2O8W1'><tfoot id='2O8W1'></tfoot><dl id='2O8W1'><fieldset id='2O8W1'></fieldset></dl></div>
                    <bdo id='2O8W1'></bdo><ul id='2O8W1'></ul>
                  <legend id='2O8W1'><style id='2O8W1'><dir id='2O8W1'><q id='2O8W1'></q></dir></style></legend>
                2. <tfoot id='2O8W1'></tfoot>

                  <small id='2O8W1'></small><noframes id='2O8W1'>