Community
Participate
Working Groups
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.
Makes complete sense to add such a warning.
Done, released into HEAD (2.1 stream).
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.
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
*** Bug 21109 has been marked as a duplicate of this bug. ***
Verified.