Bug 138184 - [search] Type Dialog (Could not uniquely map the name to a type)
Summary: [search] Type Dialog (Could not uniquely map the name to a type)
Status: VERIFIED FIXED
Alias: None
Product: JDT
Classification: Eclipse Project
Component: Core (show other bugs)
Version: 3.3   Edit
Hardware: PC Windows 2000
: P3 normal (vote)
Target Milestone: 3.4 M2   Edit
Assignee: Frederic Fusier CLA
QA Contact:
URL:
Whiteboard:
Keywords:
: 140117 199392 (view as bug list)
Depends on:
Blocks:
 
Reported: 2006-04-24 09:38 EDT by guard.cerberus CLA
Modified: 2010-09-01 12:40 EDT (History)
3 users (show)

See Also:


Attachments
Workspace demonstrating the problem (25.61 KB, application/octet-stream)
2006-04-24 09:44 EDT, guard.cerberus CLA
no flags Details
Proposed patch (11.67 KB, patch)
2007-08-09 12:43 EDT, Frederic Fusier CLA
no flags Details | Diff
New proposed patch (13.58 KB, patch)
2007-08-10 04:11 EDT, Frederic Fusier CLA
no flags Details | Diff
Patch for Eclipse 3.2.2 (1.59 KB, patch)
2008-11-27 04:13 EST, Jakub Jurkiewicz CLA
no flags Details | Diff
Proposed patch for R3_2_maintenance branch (16.16 KB, text/plain)
2008-12-11 11:57 EST, Frederic Fusier CLA
no flags Details
Proposed patch for R3_3_maintenance branch (16.98 KB, patch)
2008-12-11 12:44 EST, Frederic Fusier CLA
no flags Details | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description guard.cerberus CLA 2006-04-24 09:38:44 EDT
Trying to find an existing class in the type dialog results in the error message 
"Could not uniquely map the name to a type. Path is .." 

The type dialog ('s indexing) seems to fail when the project name contains a dot '.'.

Also see attached workspace.
Comment 1 guard.cerberus CLA 2006-04-24 09:44:50 EDT
Created attachment 39273 [details]
Workspace demonstrating the problem

Try to open MyClass from projectTest.jar - this fails with the described error message
Try to open MyClass from TestProjectWithoutDot - OK
Comment 2 Martin Aeschlimann CLA 2006-04-24 14:33:16 EDT
Thanks for the workspace. Reproduced with 20060424-0010

There are two types MyClass in two projects:
The first has as 'path' reported be the search engine
/TestProjectWithoutDot/test-src/com/test/myclass/MyClassTest.java
the second
/Test.jar|test-src/com/test/myclass/MyClassTest.java

But 'Test.jar' is a project name in this workspace.

Moving to jdt.core
Comment 3 Jerome Lanneluc CLA 2006-04-25 07:35:33 EDT
The documentPath given to the requestor is wrong. It assumes it is a jar document path (i.e "/Test.jar|src/p/MyClass.java").

Problem comes from InternalSearchPattern#documentPath(String, String) that assumes that a container path ending with .jar is a jar file path.
Comment 4 Jerome Lanneluc CLA 2006-04-25 07:36:38 EDT
One possible fix would be to encode the fact that it is a jar path in the container path (by adding '|' to the path for example).
Comment 5 Jerome Lanneluc CLA 2006-04-25 07:37:54 EDT
Since this bug existed in 3.1, this is not a regression. 

Fixing it at this stage of 3.2 is too risky. Will keep for post 3.2.
Comment 6 Jerome Lanneluc CLA 2006-05-04 06:12:58 EDT
*** Bug 140117 has been marked as a duplicate of this bug. ***
Comment 7 Louis Jacomet CLA 2007-04-17 03:58:23 EDT
The problem persists in 3.3 stream, but in a worse fashion as the Open Type dialog is now even more broken.
Where previously only the opening of the type was failing, now searching with patterns matching a type in a ".jar" project fails to show any type, from the ".jar" project, but also from any other projects or referenced libraries.
Comment 8 Jerome Lanneluc CLA 2007-04-17 04:30:10 EDT
(In reply to comment #7)
It sounds like a different problem. Please open a separate bug with detailed steps to reproduce.
Comment 9 guard.cerberus CLA 2007-07-13 03:46:00 EDT
Tested the original workspace again in 3.3. Type Dialog now produces an error message.

'Items filtering (Time of error: July 13, 2007 9:39:21 AM GMT+2:00) 
Reason:
Class file name must end with .class'

See below .log file from the workspace 

!ENTRY org.eclipse.core.jobs 4 2 2007-07-13 09:39:21.586
!MESSAGE An internal error occurred during: "Items filtering".
!STACK 0
java.lang.IllegalArgumentException: Class file name must end with .class
        at org.eclipse.jdt.internal.core.PackageFragment.getClassFile(PackageFragment.java:188)
        at org.eclipse.jdt.internal.core.search.TypeNameMatchRequestorWrapper.createTypeFromJar(TypeNameMatchRequestorWrapper.java:146)
        at org.eclipse.jdt.internal.core.search.TypeNameMatchRequestorWrapper.acceptType(TypeNameMatchRequestorWrapper.java:108)
        at org.eclipse.jdt.internal.core.search.BasicSearchEngine$2.acceptIndexMatch(BasicSearchEngine.java:767)
        at org.eclipse.jdt.internal.core.search.matching.InternalSearchPattern.acceptMatch(InternalSearchPattern.java:45)
        at org.eclipse.jdt.internal.core.search.matching.InternalSearchPattern.findIndexMatches(InternalSearchPattern.java:89)
        at org.eclipse.jdt.internal.core.search.matching.MatchLocator.findIndexMatches(MatchLocator.java:325)
        at org.eclipse.jdt.internal.core.search.PatternSearchJob.search(PatternSearchJob.java:114)
        at org.eclipse.jdt.internal.core.search.PatternSearchJob.execute(PatternSearchJob.java:64)
        at org.eclipse.jdt.internal.core.search.processing.JobManager.performConcurrentJob(JobManager.java:279)
        at org.eclipse.jdt.internal.core.search.BasicSearchEngine.searchAllTypeNames(BasicSearchEngine.java:778)
        at org.eclipse.jdt.core.search.SearchEngine.searchAllTypeNames(SearchEngine.java:781)
        at org.eclipse.jdt.internal.ui.dialogs.FilteredTypesSelectionDialog.fillContentProvider(FilteredTypesSelectionDialog.java:593)
        at org.eclipse.ui.dialogs.FilteredItemsSelectionDialog$FilterJob.filterContent(FilteredItemsSelectionDialog.java:2059)
        at org.eclipse.ui.dialogs.FilteredItemsSelectionDialog$FilterJob.internalRun(FilteredItemsSelectionDialog.java:2001)
        at org.eclipse.ui.dialogs.FilteredItemsSelectionDialog$FilterJob.doRun(FilteredItemsSelectionDialog.java:1973)
        at org.eclipse.ui.dialogs.FilteredItemsSelectionDialog$FilterJob.run(FilteredItemsSelectionDialog.java:1960)
        at org.eclipse.core.internal.jobs.Worker.run(Worker.java:55)
Comment 10 Jerome Lanneluc CLA 2007-08-09 05:33:49 EDT
(In reply to comment #9)
This is also a different problem (different error message). Please enter a separate  bug with steps to reproduce.
Comment 11 guard.cerberus CLA 2007-08-09 06:38:35 EDT
registered bug  
#199392 'Type Dialog Error 'Items filtering ... Reason: Class file name must end with .class''

Marked this bug as invalid for version 3.3.
Comment 12 Frederic Fusier CLA 2007-08-09 12:25:56 EDT
Reopen as it appears finally that it was the same issue than bug 199392.

The message has changed because Open Type dialog uses a different API method from SearchEngine (TypeNameMatchRequestor instead of TypeNameRequestor) since 3.3...
Comment 13 Frederic Fusier CLA 2007-08-09 12:29:00 EDT
*** Bug 199392 has been marked as a duplicate of this bug. ***
Comment 14 Frederic Fusier CLA 2007-08-09 12:43:45 EDT
Created attachment 75775 [details]
Proposed patch

All JDT/Core model and JDT/UI tests pass with this patch.
Comment 15 Frederic Fusier CLA 2007-08-10 04:11:52 EDT
Created attachment 75822 [details]
New proposed patch

New patch using char for separator instead of string to reduce memory allocation and speed-up concatenation just a little bit...
Comment 16 Frederic Fusier CLA 2007-08-10 04:12:45 EDT
Released for 3.4M2 in HEAD stream.
Comment 17 Eric Jodet CLA 2007-09-18 03:38:47 EDT
Verified for 3.4 M2 using build I20070917-0010.
Comment 18 Jerome Lanneluc CLA 2007-10-08 06:59:07 EDT
Might be fixed in R3_3_maintenance by fix for bug 204652. Frederic please verify that assumption.
Comment 19 Frederic Fusier CLA 2007-10-09 13:57:34 EDT
(In reply to comment #18)
> Might be fixed in R3_3_maintenance by fix for bug 204652. Frederic please
> verify that assumption.
> 
Unfortunately not, as we get a "Class file name must ends with .class" error with the fix released in maintenance stream for bug 204652.

JavaSearchScope behaves correctly with the patch, but in comment 2 test case, there's a java file (MyClass.java) in the source folder and this error is raised as the TypeNameMatchRequestorWrapper expects to find a class file in a jar file (method #createTypeFromJar(String, int))...

So, to definitely avoid this error, the only way is not to jump into this method reserved to Jar files and I currently do not see any simple workaround to fix this in maintenance stream...
Comment 20 Jakub Jurkiewicz CLA 2008-11-27 04:13:51 EST
Created attachment 118873 [details]
Patch for Eclipse 3.2.2

RAD 7.0 (based on Eclipse 3.2.2) is facing this problem. I have prepared a patch, so that it could be included in one of the future fixes fix for RAD 7.0.
Comment 21 Jerome Lanneluc CLA 2008-12-11 09:56:21 EST
Looking at the patch from comment 20, "ResourcesPlugin.getWorkspace().getRoot().getProject(containerPath) != null" always returns true (so it is not needed), but more importantly it doesn't work if the path to the jar is "C:\mylib.jar" since "(new Path(containerPath).segmentCount() == 1" returns true in this case.

Frederic, do you agree that this patch is not correct?
Comment 22 Frederic Fusier CLA 2008-12-11 10:22:27 EST
(In reply to comment #21)
> Looking at the patch from comment 20,
> "ResourcesPlugin.getWorkspace().getRoot().getProject(containerPath) != null"
> always returns true (so it is not needed), but more importantly it doesn't work
> if the path to the jar is "C:\mylib.jar" since "(new
> Path(containerPath).segmentCount() == 1" returns true in this case.
> 
> Frederic, do you agree that this patch is not correct?
> 
Definitely agree
Comment 23 Jerome Lanneluc CLA 2008-12-11 10:40:21 EST
Correct fix would involve backporting the fix from comment 15 + the fix from bug 200064.
Comment 24 Frederic Fusier CLA 2008-12-11 11:57:46 EST
Created attachment 120216 [details]
Proposed patch for R3_2_maintenance branch
Comment 25 Frederic Fusier CLA 2008-12-11 12:44:56 EST
Created attachment 120225 [details]
Proposed patch for R3_3_maintenance branch
Comment 26 Jerome Lanneluc CLA 2008-12-16 09:56:55 EST
(In reply to comment #24)
> Created an attachment (id=120216) [details]
> Proposed patch for R3_2_maintenance branch
> 
Released in R3_2_maintenance branch
Comment 27 Jerome Lanneluc CLA 2008-12-17 04:33:49 EST
(In reply to comment #25)
> Created an attachment (id=120225) [details]
> Proposed patch for R3_3_maintenance branch
> 
Released in R3_3_maintenance branch
Comment 28 Jared Burns CLA 2010-08-26 19:47:49 EDT
I currently have an Eclipse 3.5.2 workspace (my RTC install) which is exibiting this problem. I can't use the Open Type dialog anymore because of the error:
  java.lang.IllegalArgumentException: Class file name must end with .class

It looks like this workitem was resolved in Eclipse 3.4, so should I open a new workitem to track the problem in 3.5? Or should I reopen this one?

Also, is there any workaround I can use to restore the use of the Open Type dialog?
Comment 29 Frederic Fusier CLA 2010-08-27 04:16:53 EDT
(In reply to comment #28)
> I currently have an Eclipse 3.5.2 workspace (my RTC install) which is exibiting
> this problem. I can't use the Open Type dialog anymore because of the error:
>   java.lang.IllegalArgumentException: Class file name must end with .class
> 
> It looks like this workitem was resolved in Eclipse 3.4, so should I open a new
> workitem to track the problem in 3.5? Or should I reopen this one?
> 
> Also, is there any workaround I can use to restore the use of the Open Type
> dialog?

Jared,

Your problem sounds more like bug 286379 than this one. Unfortunately, there's no workaround for it. Perhaps removing all the index files to trigger a new full re-indexing, as described in bug 286379 comment 38, could make this issue disappearing for a while...
Comment 30 Jared Burns CLA 2010-09-01 12:40:40 EDT
(In reply to comment #29)
> Your problem sounds more like bug 286379 than this one. Unfortunately, there's
> no workaround for it. Perhaps removing all the index files to trigger a new
> full re-indexing, as described in bug 286379 comment 38, could make this issue
> disappearing for a while...

This workaround fixed the problem. Thanks.