Bug 327106 - The warning "Indirect access to static member" sometimes reports wrong hits
Summary: The warning "Indirect access to static member" sometimes reports wrong hits
Status: VERIFIED INVALID
Alias: None
Product: JDT
Classification: Eclipse Project
Component: Core (show other bugs)
Version: 3.7   Edit
Hardware: PC Windows XP
: P3 normal (vote)
Target Milestone: 3.7 M3   Edit
Assignee: Olivier Thomann CLA
QA Contact:
URL:
Whiteboard:
Keywords:
Depends on:
Blocks:
 
Reported: 2010-10-06 10:01 EDT by Sebastian Dietrich CLA
Modified: 2010-10-26 10:09 EDT (History)
2 users (show)

See Also:


Attachments
eclipse project to show the bug (4.14 KB, application/octet-stream)
2010-10-08 18:13 EDT, Sebastian Dietrich CLA
no flags Details

Note You need to log in before you can comment on or make changes to this bug.
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