Bug 124645 - [search] for implementors does not find subclasses of binary classes
Summary: [search] for implementors does not find subclasses of binary classes
Status: VERIFIED FIXED
Alias: None
Product: JDT
Classification: Eclipse Project
Component: Core (show other bugs)
Version: 3.2   Edit
Hardware: PC Windows XP
: P3 normal (vote)
Target Milestone: 3.2 RC1   Edit
Assignee: Frederic Fusier CLA
QA Contact:
URL:
Whiteboard:
Keywords:
Depends on:
Blocks:
 
Reported: 2006-01-20 09:37 EST by Markus Keller CLA
Modified: 2006-04-13 11:41 EDT (History)
3 users (show)

See Also:


Attachments
Patch to implement this change (8.01 KB, application/octet-stream)
2006-04-11 12:49 EDT, Frederic Fusier CLA
no flags Details
Tests have been rewritten to match exactly the bug test case (10.44 KB, patch)
2006-04-12 04:30 EDT, 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 Markus Keller CLA 2006-01-20 09:37:44 EST
HEAD

With the fix for bug 122442, search for IJavaSearchConstants.IMPLEMENTORS should now also find subclasses of the target class. This does not work for binary classes:

- have xy/Test.java:
package xy;
public class Test extends Exception { }
-> search for implementors of Exception find nothing

And now comes the fun part (-:
- add a space somewhere in the editor and then do the search again
-> Hooray, Test is found!
I guess that's because there's no index for dirty editors.

- change the class declaration to look like this (this time, save the editor):
public class Test extends  Exception {
    void m() {
        new Exception() { /* anonymous */ };
    }
}
-> Now, search finds both implementors (Test and the anonymous).
I guess that's because the anonymous is in the index and as soon as there's an index match, the whole file is examined thoroughly.
Comment 1 Frederic Fusier CLA 2006-01-22 05:38:08 EST
You're right for the first point. I mean, Search engine find the implementors because it does not use indexing for working copy.

For the second point (ie. anonymous) it's a little bit more complicated...
Search engine find reference due to fix of bug 3442 in method notifySourceElementRequestor(TypeDeclaration, boolean, TypeDeclaration) of SourceElementParser (line 1224). In case of anonymous without superinterface, the parser sets it with expression type. This has for consequence that indexer store a key with interface flavor for Exception super type and so return Test.java as a candidate CU for the search request (note that this fix sounds really strange as it puts a class in superinterface table... It was done a long time ago on 2.0, so I have to double-check with Olivier if this was intentional or he missed this case at that time...).

Looking at all code concerning implementors search request, it seems that my conclusion in bug 12442 comment 11 was wrong (again). I discovered that indexer have filters to exclude superclasses since the beginning (bug 1G5HBQA: ITPJUI:WINNT). This seems to prove that Search Engine initial design was not to report superclasses while searching for class implementors but unfortunately have some bugs in implementation which make me thought the opposite... I'll talk with Philippe and Jerome to see whether we finally decide to keep initially intended design or change it to accept to find superclasses...
Comment 2 Markus Keller CLA 2006-01-23 04:50:39 EST
Re "anonymous of a class has super interface", see also bug 86313 (type kind of anonymous can't be determined without resolving).
Comment 3 Frederic Fusier CLA 2006-04-03 11:04:42 EDT
I think it's a good candidate for RC1
Comment 4 Philipe Mulet CLA 2006-04-03 12:21:16 EDT
+1
Comment 5 Frederic Fusier CLA 2006-04-11 12:49:19 EDT
Created attachment 38302 [details]
Patch to implement this change

Contains patch file + jar for tests.
Comment 6 Frederic Fusier CLA 2006-04-12 04:30:45 EDT
Created attachment 38387 [details]
Tests have been rewritten to match exactly the bug test case

Previous tests pass but didn't match exactly the test case as the searched class were not a binary one.
I've rewrite them and search implementors for a binary class both in source and binary files...

Jar files are unchanged from previous patch (so it's not completely obsolete...)
Comment 7 Frederic Fusier CLA 2006-04-12 09:06:07 EDT
Patch released in HEAD.
Comment 8 Jerome Lanneluc CLA 2006-04-13 11:41:45 EDT
Verified for 3.2 RC1 using build I20060413-0010