Bug 21109 - Have option for compiler warning on use of static field/method through reference
Summary: Have option for compiler warning on use of static field/method through reference
Status: RESOLVED DUPLICATE of bug 21787
Alias: None
Product: JDT
Classification: Eclipse Project
Component: Core (show other bugs)
Version: 2.0   Edit
Hardware: All All
: P3 enhancement (vote)
Target Milestone: 2.1   Edit
Assignee: Philipe Mulet CLA
QA Contact:
URL:
Whiteboard:
Keywords:
Depends on:
Blocks:
 
Reported: 2002-06-28 06:30 EDT by Jon Skeet CLA
Modified: 2002-07-25 06:48 EDT (History)
0 users

See Also:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Jon Skeet CLA 2002-06-28 06:30:04 EDT
One of the really nasty (IMO, and in the opinion of others) "features" of the
Java languages is the ability to access static methods/fields through
references, where the type of the reference is used rather than anything else.
For instance:

    Foo b = new Bar();
    b.staticMethod(); 
calls Foo.staticMethod();
as does:
    Foo n = null;
    n.staticMethod();

This is generally a really bad idea. Is there any chance that we could have a
configurable compiler warning for it, as with things like unused parameters?

Jon
Comment 1 Philipe Mulet CLA 2002-06-28 07:03:08 EDT
Good suggestion, should consider post 2.0
Comment 2 Philipe Mulet CLA 2002-07-25 06:47:55 EDT
Fixed as bug 21787
Comment 3 Philipe Mulet CLA 2002-07-25 06:48:12 EDT

*** This bug has been marked as a duplicate of 21787 ***