Some Eclipse Foundation services are deprecated, or will be soon. Please ensure you've read this important communication.

Bug 420345

Summary: Incorrect behavior of Util.getUnresolvedJavaElement(...) method
Product: [Eclipse Project] JDT Reporter: Hubert Lei <hubert.lei>
Component: CoreAssignee: Jay Arthanareeswaran <jarthana>
Status: CLOSED WONTFIX QA Contact:
Severity: normal    
Priority: P3 CC: srikanth_sankaran
Version: 4.3.1   
Target Milestone: ---   
Hardware: PC   
OS: Linux-GTK   
Whiteboard: stalebug
Attachments:
Description Flags
use case none

Description Hubert Lei CLA 2013-10-24 21:28:35 EDT
Created attachment 236867 [details]
use case

This issue is similar to Bug 249567, but not exactly the same.

There are two classes defined within different packages in the same project, but they have the same simple name,e.g. "FrontTyre". A third class can use these two classes as the parameter types of two methods declarations respectively, while those two methods declarations have the same simple name too:

package com.hubert.brandshow;

import com.hubert.merida.FrontTyre;

public class Bike {
	public void showTyre(com.hubert.giant.FrontTyre ft){
		System.out.println(ft.getBrand());
	}
	
//a simple name is used instead of complete name as the parameter type
	public void showTyre(FrontTyre ft){
		System.out.println(ft.getBrand());
	}
}

When parsing the second method declaration, there is an error.

Our parse procedure is following:
1. Acquire methodBinding via IMethodBinding.resolveBinding() method
2. Invoke getJavaElement() method on the method binding to get IMethod.

The first step results in a method binding 
"public void showTyre(com.hubert.merida.FrontTyre)", 
while the second returns the INCORRECT IMethod 
"void showTyre(com.hubert.giant.FrontTyre".

Through debugging, I found in Util.getUnresolvedJavaElement(...), line 1434 can return a correct IMethod, but in line 1437, the result is recognized as not existent. Thus, a wrong result is returned. This might be related to 
" org.eclipse.jdt.internal.core.JavaModelManager.getInfo(IJavaElement element)
"
Complete use case is attached.
Comment 1 Jay Arthanareeswaran CLA 2013-10-25 00:30:10 EDT
Hubert, thanks for the report and analysis. Unfortunately, the JDT core team is busy with Java8 work and may not find time to look at this soon. But if you can come up with a patch, we will be happy to look at it.
Comment 2 Eclipse Genie CLA 2019-12-09 09:13:26 EST
This bug hasn't had any activity in quite some time. Maybe the problem got resolved, was a duplicate of something else, or became less pressing for some reason - or maybe it's still relevant but just hasn't been looked at yet.

If you have further information on the current state of the bug, please add it. The information can be, for example, that the problem still occurs, that you still want the feature, that more information is needed, or that the bug is (for whatever reason) no longer relevant.

--
The automated Eclipse Genie.