Bug 45662 - non static access to static member incorrectly identifies chained method calls
Summary: non static access to static member incorrectly identifies chained method calls
Status: RESOLVED INVALID
Alias: None
Product: JDT
Classification: Eclipse Project
Component: Core (show other bugs)
Version: 3.0   Edit
Hardware: All All
: P3 minor (vote)
Target Milestone: 3.0 M5   Edit
Assignee: JDT-Core-Inbox CLA
QA Contact:
URL:
Whiteboard:
Keywords:
Depends on:
Blocks:
 
Reported: 2003-10-28 08:21 EST by Channing Walton CLA
Modified: 2003-10-29 04:48 EST (History)
0 users

See Also:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Channing Walton CLA 2003-10-28 08:21:02 EST
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.
Comment 1 Olivier Thomann CLA 2003-10-28 15:18:54 EST
Could you please provide a complete example?
Thanks.
Comment 2 Channing Walton CLA 2003-10-28 15:39:01 EST
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'
Comment 3 Philipe Mulet CLA 2003-10-28 17:17:48 EST
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 ?
Comment 4 Channing Walton CLA 2003-10-29 02:16:20 EST
ok
Comment 5 Philipe Mulet CLA 2003-10-29 04:48:26 EST
Closing