Summary: | non static access to static member incorrectly identifies chained method calls | ||
---|---|---|---|
Product: | [Eclipse Project] JDT | Reporter: | Channing Walton <channingwalton> |
Component: | Core | Assignee: | JDT-Core-Inbox <jdt-core-inbox> |
Status: | RESOLVED INVALID | QA Contact: | |
Severity: | minor | ||
Priority: | P3 | ||
Version: | 3.0 | ||
Target Milestone: | 3.0 M5 | ||
Hardware: | All | ||
OS: | All | ||
Whiteboard: |
Description
Channing Walton
2003-10-28 08:21:02 EST
Could you please provide a complete example? Thanks. public class Test { private static final Test test = new Test(); public static Test foo() { return test; } public static Test bar() { return test; } public static void main(String[] args) { Test.foo().bar(); // marker placed against this line } } A marker (warning in my case) is placed against the line 'Test.foo().bar()' saying 'The static method bar() from the type Test should be accessed in a static way' Along the chain, each method call returns a value used as a receiver for the next invocation, though the subsequent method is static and the receiver value is actually ignored. This is all this warning is trying to tell you. The following code would be equivalent. public class Test { public static void foo() { } public static void bar() { } public static void main(String[] args) { Test.foo(); Test.bar(); } } If you dislike this warning, you can turn it off in the compiler preferences. Ok to close ? ok Closing |