Bug 120766 - problems when using classes of the same name
Summary: problems when using classes of the same name
Status: VERIFIED FIXED
Alias: None
Product: JDT
Classification: Eclipse Project
Component: Core (show other bugs)
Version: 3.1.1   Edit
Hardware: PC Windows XP
: P3 normal (vote)
Target Milestone: 3.4 M1   Edit
Assignee: David Audel CLA
QA Contact:
URL:
Whiteboard:
Keywords:
Depends on:
Blocks:
 
Reported: 2005-12-13 18:03 EST by Hosam CLA
Modified: 2007-08-03 06:52 EDT (History)
0 users

See Also:


Attachments
Proposed fix (3.46 KB, patch)
2007-06-28 06:19 EDT, David Audel CLA
no flags Details | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description Hosam CLA 2005-12-13 18:03:32 EST
I'm sorry, but I couldn't make a good summary for this bug. Please feel free to change it!

I had imported javax.crypto.KeyGenerator in my java file. Then, I was writing the following code:

abc.KeyGenerator keygen = new abc.KeyGenerator();

Ctrl+Clicking on KeyGenerator in the above statement would take me to the source of javax.crypto.KeyGenerator. It should have went to abc.KeyGenerator.

Actually, the above statement was syntactically wrong because my KeyGenerator did not have a default constructor. The syntax error seems to be causing this problem.
Comment 1 Martin Aeschlimann CLA 2005-12-14 09:11:12 EST
What I could reproduce is that a code resolve on 'abc.KeyGenerator()' returns 2 results. I didn't see the problem that the wrong type was opened directly.

But also returning 2 results could be improved. The type is clearly known here.

package p;
public class Bar {
	abc.KeyGenerator keygen = new abc.KeyGenerator();
}


Moving to jdt.core.
Comment 2 David Audel CLA 2007-06-28 06:19:58 EDT
Created attachment 72670 [details]
Proposed fix
Comment 3 David Audel CLA 2007-06-28 06:24:16 EDT
Released for 3.4M1

Test added
  ResolveTests#testDuplicateTypeDeclaration8()

When an unknown constructor of a valid type is selected then the type is returned.
Comment 4 Frederic Fusier CLA 2007-08-03 06:51:25 EDT
Verified for 3.4M1 using build I20070802-0800.
Comment 5 Frederic Fusier CLA 2007-08-03 06:52:59 EDT
The test case I used to reproduce the problem is:

package abc;
public class KeyGenerator {
	 KeyGenerator(String str) {}
}

package p;
public class Bar {
        abc.KeyGenerator keygen = new abc.KeyGenerator();
}

Select the constructor call in Bar and hit F3...