Bug 46929 - Javac and Override annotation
Summary: Javac and Override annotation
Status: RESOLVED INVALID
Alias: None
Product: Ant
Classification: Unclassified
Component: Core tasks (show other bugs)
Version: 1.7.1
Hardware: PC Windows XP
: P2 normal (vote)
Target Milestone: 1.8.0
Assignee: Ant Notifications List
URL:
Keywords: ErrorMessage
Depends on:
Blocks:
 
Reported: 2009-03-27 10:44 UTC by Kathy
Modified: 2009-04-09 07:26 UTC (History)
1 user (show)



Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Kathy 2009-03-27 10:44:15 UTC
When I use @Override the implementation of a method from the parent interface, I get a compiler error when calling the "javac" ant task. Eclipse is using the same compiler and does not throw an error. While the Java 6 documentation is vague on this scenario, from what I understand you can use the @Override annotation for overriding and implementing abstract methods. 

    <echo>JAVA_HOME: ${java.home}</echo>
    <echo>ANT_HOME: ${ant.home}</echo>
    <echo>Ant Java Version: ${ant.java.version}</echo>
    <echo>Ant Version: ${ant.version}</echo>
    <echo>Java Version: ${java.version}</echo>

Results in:

     [echo] JAVA_HOME: C:\Program Files\Java\jre1.6.0_05
     [echo] ANT_HOME: C:\Program Files\Apache Software Foundation\apache-ant-1.7.1
     [echo] Ant Java Version: 1.6
     [echo] Ant Version: Apache Ant version 1.7.1 compiled on June 27 2008
     [echo] Java Version: 1.6.0_05

Output (removed some directory information for privacy):

    [javac] Compiling 1 source file to ...\build\classes
    [javac] ...\XmlParserErrorResults.java:64: method does not override a method from its superclass
    [javac]   @Override
    [javac]    ^
    [javac] 1 error

Work around:
Simply remove the "@Override" annotation and the problem is resolved. However, this seems like a pretty poor work around.

Testing:
As expected, if I legitimately break the code, by deleting the abstract method from my interface, I get the same error from "javac," but now I get it from Eclipse as well.
Comment 1 Stefan Bodewig 2009-04-09 07:26:02 UTC
I don't think eclipse is using the same compiler as Ant, don't they have an incremental compiler in JDT?

Anyway, the error message isn't Ant's but the compiler's error message and I don't see how/if Ant could/should change anything about it.

If this is a bug, it is not Ant's.