Community
Participate
Working Groups
Using a Jakarta example, code like this: OptionBuilder.withArgName( "file" ).hasArg().withDescription( "use given file for log" ).create( "file"); the 'non static access to static member' compiler option generates a marker. But there is no non static access.
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