Bug 21109

Summary: Have option for compiler warning on use of static field/method through reference
Product: [Eclipse Project] JDT Reporter: Jon Skeet <skeet>
Component: CoreAssignee: Philipe Mulet <philippe_mulet>
Status: RESOLVED DUPLICATE QA Contact:
Severity: enhancement    
Priority: P3    
Version: 2.0   
Target Milestone: 2.1   
Hardware: All   
OS: All   
Whiteboard:

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 ***