Bug 127442 - [search] should find binary member references in .class file and not via attached source
Summary: [search] should find binary member references in .class file and not via atta...
Status: CLOSED WONTFIX
Alias: None
Product: JDT
Classification: Eclipse Project
Component: Core (show other bugs)
Version: 3.2   Edit
Hardware: PC Windows XP
: P5 normal (vote)
Target Milestone: ---   Edit
Assignee: JDT-Core-Inbox CLA
QA Contact:
URL:
Whiteboard: stalebug
Keywords:
Depends on:
Blocks: 182346
  Show dependency tree
 
Reported: 2006-02-13 05:06 EST by Markus Keller CLA
Modified: 2020-02-06 17:52 EST (History)
6 users (show)

See Also:


Attachments
Olivier's initial patch (26.08 KB, patch)
2008-03-03 05:17 EST, Frederic Fusier CLA
no flags Details | Diff
Olivier's patch on top of HEAD (26.08 KB, patch)
2008-04-17 13:32 EDT, Frederic Fusier CLA
no flags Details | Diff
Olivier's patch updated for 3.5 (25.17 KB, patch)
2008-09-04 10:53 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-02-13 05:06:34 EST
I20060213-0010

Bug 119203 comment 5 indicates that the search engine currently does not resolve references to types/methods/fields from class files, but rather creates an AST on the attached source and then tries to resolve from there. This can lead to unexpected search results if the classpath is not 100% complete and the source cannot be compiled without errors (bug 119203, bug 127048).

If instead the already resolved reference in the classfile would be consulted, then the reference would always be accurate (or non-matching, if then qualifier is different).
Comment 1 Frederic Fusier CLA 2006-02-13 05:19:28 EST
Philippe, Olivier, I definitely need your class file knowledge to help me to figure out what can be done here...
Comment 2 Frederic Fusier CLA 2006-03-30 12:38:31 EST
Defer post 3.2
Comment 3 Frederic Fusier CLA 2006-04-11 03:08:12 EDT
Defer post 3.2
Comment 4 Jens Andersen CLA 2006-08-23 03:51:01 EDT
Any chance this bug will be fixed within the 3.3 timeframe?
Comment 5 Frederic Fusier CLA 2007-06-21 10:45:26 EDT
Reopen as we may consider it for 3.4...
Comment 6 Markus Keller CLA 2007-12-12 11:22:49 EST
It really sounds strange now that annotation references are found in class files without source (bug 211366) but other references to a type are not found.
Comment 7 Frederic Fusier CLA 2007-12-12 11:42:58 EST
(In reply to comment #6)
> It really sounds strange now that annotation references are found in class
> files without source (bug 211366) but other references to a type are not found.
> 
That means we need to fix this bug for 3.4. This should make you happy ;-)
Bug 211366 was fixed first and put in 3.4M4 as it was initially opened as critical!
Comment 8 Olivier Thomann CLA 2008-02-22 14:18:39 EST
Do we want to return potential matches as well?

For example, if you are looking for a method reference where the method takes an int as a parameter, do you want a potential match for a method reference with the same name but no parameter ?

I can return this as a potential match or I can simply return only exact matches.
Comment 9 Markus Keller CLA 2008-02-22 14:39:07 EST
I would expect the same as in the source case.
Comment 10 Olivier Thomann CLA 2008-02-22 15:53:28 EST
The problem is that if in the source, you search for a method foo(String) I cannot be sure that this is matching foo(java.lang.String). So this would be a potential match, whereas I can get an exact match if the type is fully qualified.

I'll check how this is handled in the source case.
Comment 11 Jerome Lanneluc CLA 2008-02-25 05:07:43 EST
Yes we want potential matches. However a method with different number of parameters is not a potential match. A potential match is a match where the resolution failed (e.g. the method binding is null). If the user searches for "foo(String)" (without qualifing String), then "foo(java.lang.String)" and "foo(p.String" are both exact matches.

For the .class file case, I think we can only have potential matches in the case of the missing type case (see bug 196200), i.e if the .class file was compiled and some types it references were missing.

So we will have the exact same behavior in the source case and in the binary case iff the source is complete.
Comment 12 Frederic Fusier CLA 2008-03-03 05:17:57 EST
Created attachment 91338 [details]
Olivier's initial patch

Olivier provided an initial patch which returns matches for fields and methods references but not fully tested.
Comment 13 Frederic Fusier CLA 2008-03-03 05:19:03 EST
I'll continue for types references and write complete tests for this new functionality. Only for M7 as I have other API changes to write before M6...
Comment 14 Frederic Fusier CLA 2008-04-17 13:32:24 EDT
Created attachment 96476 [details]
Olivier's patch on top of HEAD
Comment 15 Frederic Fusier CLA 2008-04-17 13:33:43 EDT
Jerome,
I had no other input than Olivier's patch updated on top of HEAD.
Thanks
Comment 16 Jerome Lanneluc CLA 2008-05-02 04:55:28 EDT
We ran out of time for 3.4. Deferring to 3.5
Comment 17 Frederic Fusier CLA 2008-09-04 10:53:23 EDT
Created attachment 111674 [details]
Olivier's patch updated for 3.5
Comment 18 Jerome Lanneluc CLA 2008-09-09 10:12:25 EDT
(In reply to comment #0)
> I20060213-0010
> 
> Bug 119203 comment 5 indicates that the search engine currently does not
> resolve references to types/methods/fields from class files, but rather creates
> an AST on the attached source and then tries to resolve from there. This can
> lead to unexpected search results if the classpath is not 100% complete and the
> source cannot be compiled without errors (bug 119203, bug 127048).
> 
> If instead the already resolved reference in the classfile would be consulted,
> then the reference would always be accurate (or non-matching, if then qualifier
> is different).
The reference would indeed be accurate but it would contain no source position. I.e. if the user double-clicks on the result in the Search view, it will not show the position of the reference in the attached source. It would be a regression.

However implementing method/field/type references for .class files with no source attached would be an improvement.

Comment 19 Markus Keller CLA 2008-09-09 13:29:28 EDT
> The reference would indeed be accurate but it would contain no source position.
> I.e. if the user double-clicks on the result in the Search view, it will not
> show the position of the reference in the attached source. It would be a
> regression.

Good point. I guess the line number attributes in the class file could sometimes be used to select at least the matching line, but debug info is optional and it may be hard to implement for type references. So I agree it's better to live with inaccurate matches in this case for now (until bug 110176 gives hierarchical classpaths).
Comment 20 Frederic Fusier CLA 2008-09-15 12:45:03 EDT
Comment on attachment 111674 [details]
Olivier's patch updated for 3.5

This patch does not respond to desired functionality. It only finds references in .class files which do not have any attached source but still parse sources first when available...
Comment 21 Frederic Fusier CLA 2008-09-15 12:45:59 EDT
See bug 247045 to follow work progress on finding references in .class files without sources...
Comment 22 Eclipse Genie CLA 2020-02-06 15:10:51 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. As such, we're closing this bug.

If you have further information on the current state of the bug, please add it and reopen this bug. 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.