Bug 21787 - Provide compiler warning of using static method via non-static style.
Summary: Provide compiler warning of using static method via non-static style.
Status: VERIFIED FIXED
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 M1   Edit
Assignee: Philipe Mulet CLA
QA Contact:
URL:
Whiteboard:
Keywords:
: 21109 (view as bug list)
Depends on:
Blocks:
 
Reported: 2002-07-22 21:04 EDT by Eric Nickell CLA
Modified: 2002-09-19 05:16 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 Eric Nickell CLA 2002-07-22 21:04:05 EDT
I've been bitten by this twice now, and some compiler assistance would be
appreciated. I'm using an API class, Foo, which has a non-static method ("cat")
which take 3 Foo args, and a static method of the same name which takes 4 Foo
args.  Twice, I've supplied one too many args, a la "s0.cat(s1, s2, null,
null)", where I intended "s0.cat(s1, s2, null)", but with the effect
"Foo.cat(s1, s2, null, null)".  Bleah.

I would like a compiler error implemented which flags calls to static methods
using object notation.  Fine by me if the initial setting in
Window/Preferences/Java/Compiler/Errors and Warnings is "Ignore" so that there
is no behavior change for the default.
Comment 1 Philipe Mulet CLA 2002-07-23 06:45:12 EDT
Makes complete sense to add such a warning.
Comment 2 Philipe Mulet CLA 2002-07-23 08:57:54 EDT
Done, released into HEAD (2.1 stream).
Comment 3 Philipe Mulet CLA 2002-07-23 09:12:36 EDT
Added compiler option for this purpose.

JavaCore.COMPILER_PB_STATIC_ACCESS_RECEIVER

Entered UI defect (bug 21804) for this setting to be surfaced in preference 
page.
Comment 4 Philipe Mulet CLA 2002-07-23 09:56:34 EDT
Until UI preference is added, this mode can be used by manually editing the 
preference file for JDT/Core:

<workspace>/.metadata/.plugins/org.eclipse.jdt.core/pref_store.ini

Add the line:

org.eclipse.jdt.core.compiler.problem.staticAccessReceiver=warning
Comment 5 Philipe Mulet CLA 2002-07-25 06:48:13 EDT
*** Bug 21109 has been marked as a duplicate of this bug. ***
Comment 6 David Audel CLA 2002-09-19 05:16:44 EDT
Verified.