Bug 90111 - [1.5][compiler] Compiler warning "tagged with @Override" not correct with static methods
Summary: [1.5][compiler] Compiler warning "tagged with @Override" not correct with sta...
Status: VERIFIED FIXED
Alias: None
Product: JDT
Classification: Eclipse Project
Component: Core (show other bugs)
Version: 3.1   Edit
Hardware: All All
: P3 normal (vote)
Target Milestone: 3.1 M7   Edit
Assignee: Philipe Mulet CLA
QA Contact:
URL:
Whiteboard:
Keywords:
Depends on:
Blocks:
 
Reported: 2005-04-03 08:03 EDT by Sebastian Davids CLA
Modified: 2005-05-11 11:25 EDT (History)
1 user (show)

See Also:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Sebastian Davids CLA 2005-04-03 08:03:05 EDT
Test case:

class Super {

    static void notOverridden() {
        return;
    }
}

public class Test extends Super {

    static void notOverridden() {
        return;
    }
}

@@@@

Static methods cannot be overridden but they're hidden (see
http://java.sun.com/docs/books/jls/second_edition/html/classes.doc.html#227928 ).

So the current message is wrong.

However having the warning is appreciated because hiding static methods is a
common programming error for new programmers.

Opened bug 90110 for an additional compiler flag.
Comment 1 Sebastian Davids CLA 2005-04-03 08:09:07 EDT
Version: 3.1.0
Build id: I20050401-1645
Comment 2 Philipe Mulet CLA 2005-04-04 07:06:50 EDT
Added AnnotationTest#test123-124.
Fixed, by turning off complaining in presence of static method.
Comment 3 Adam Kiezun CLA 2005-05-10 09:59:12 EDT
does this also take care of the folowing?

public class Foo {
  static void foo(){}
}
class Bar extends Foo{
  @Override  //should be an error (bug in 3.1M6)
  static void foo(){}	
}
Comment 4 Philipe Mulet CLA 2005-05-10 15:31:03 EDT
We do not complain on latter case, and javac agrees with us. 
Comment 5 Philipe Mulet CLA 2005-05-10 15:36:30 EDT
Added AnnotationTest#tes140
Comment 6 Adam Kiezun CLA 2005-05-10 15:51:16 EDT
am I correct that it is a bug (in both eclipse and javac)?
Comment 7 Philipe Mulet CLA 2005-05-10 18:00:46 EDT
@Override is not very strictly spec'ed... so one could say it is a matter of
interpretation. If you feel it is bad, please enter a separate defect about your
latter issue, for later investigating. For current time being, there are other
more critical issues; and given our behavior seems to match others expectation...
Comment 8 Adam Kiezun CLA 2005-05-10 18:10:22 EDT
will do. i understand it's not high prio though.

@Override javadoc says "Indicates that a method declaration is intended to
override a method declaration in a superclass."

And method overriding (jls3 8.4.8.1) says that overriding only applies to
instance methods.
Comment 9 Olivier Thomann CLA 2005-05-11 11:25:54 EDT
Verified in I20050510-0010