Bug 327106

Summary: The warning "Indirect access to static member" sometimes reports wrong hits
Product: [Eclipse Project] JDT Reporter: Sebastian Dietrich <Sebastian.Dietrich>
Component: CoreAssignee: Olivier Thomann <Olivier_Thomann>
Status: VERIFIED INVALID QA Contact:
Severity: normal    
Priority: P3 CC: amj87.iitr, Olivier_Thomann
Version: 3.7   
Target Milestone: 3.7 M3   
Hardware: PC   
OS: Windows XP   
Whiteboard:
Attachments:
Description Flags
eclipse project to show the bug none

Description Sebastian Dietrich CLA 2010-10-06 10:01:04 EDT
Build Identifier: 20100917-0705

The warning "Indirect access to static member" sometimes wrongly reports a problem when there is none.

Example:
import com.google.gwt.user.client.Element;
...
Element.as(body); // --> the static method as(Node) from the type Element should be accessed directly
com.google.gwt.dom.client.Element.as(body); // interrestingly this works


Reproducible: Always

Steps to Reproduce:
1.create a class
2.import com.google.gwt.user.client.Element;
3.write a method with the line "Element.as(null);"
4.set the warning "indirect access to static member" to warning or error
Comment 1 Olivier Thomann CLA 2010-10-08 14:35:00 EDT
Could you please provide a short test case that exhibits this issue?
Thanks.
Comment 2 Sebastian Dietrich CLA 2010-10-08 18:12:27 EDT
Attached you'll find a newly created eclipse project with the class as defined in "steps to reproduce"
Comment 3 Sebastian Dietrich CLA 2010-10-08 18:13:44 EDT
Created attachment 180523 [details]
eclipse project to show the bug
Comment 4 Olivier Thomann CLA 2010-10-15 10:00:30 EDT
In your test case:
The first method resolves to: com.google.gwt.user.client.Element.as(com.google.gwt.dom.client.Node) : com.google.gwt.dom.client.Element

And the second one resolves to:
com.google.gwt.dom.client.Element.as(com.google.gwt.dom.client.Node) : com.google.gwt.dom.client.Element

So these are two different methods.
The first Element.as(null) points to the class com.google.gwt.user.client.Element.

This class inherits from com.google.gwt.dom.client.Element that defines as method as(..).
So it is right that the static method is not access directly.

In the second case, you are directly accessing the static method and in this case you don't get a warning.

Therefore I am closing as INVALID. This works as expected.
Comment 5 Sebastian Dietrich CLA 2010-10-18 08:30:48 EDT
Yes - sorry, you are absolutely right.
Invalid - works as expected
Comment 6 Ayushman Jain CLA 2010-10-26 10:09:48 EDT
Verified for 3.7M3