Bug 148010 - Code select doesn't find binary parameterized method
Summary: Code select doesn't find binary parameterized method
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.1   Edit
Assignee: Olivier Thomann CLA
QA Contact:
URL:
Whiteboard:
Keywords:
: 88023 157081 (view as bug list)
Depends on:
Blocks:
 
Reported: 2006-06-21 06:14 EDT by Jerome Lanneluc CLA
Modified: 2006-09-13 05:03 EDT (History)
4 users (show)

See Also:


Attachments
Proposed fix (1.89 KB, patch)
2006-06-26 15:52 EDT, Olivier Thomann CLA
no flags Details | Diff
Regression test (1.56 KB, patch)
2006-06-26 15:59 EDT, Olivier Thomann CLA
no flags Details | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description Jerome Lanneluc CLA 2006-06-21 06:14:31 EDT
I20060620

1. Create the following CU:
import java.util.Collections;
import java.util.LinkedList;

public class SortedList<E extends Comparable> extends LinkedList<E>
{
    public boolean add(E e){
      int index = Collections.binarySearch(this,e);
      if (index<0)
      super.add(-index-1,e);
      return true;
  }
}
2. Select 'binarySearch'
3. Press F3
Observe: Collections.class is open, but binarySeach(...) is not selected.
Comment 1 Philipe Mulet CLA 2006-06-21 06:16:00 EDT
Smells like a source mapper issue.
Comment 2 Philipe Mulet CLA 2006-06-21 06:22:42 EDT
Actually, even simpler steps.
Open type on 'java.util.Collections'
Select #binarySearch(List<? extends Comparable<? super T>>, T)<T>
 in outliner

Observe nothing occurs... (no scrolling in editor)
Comment 3 Philipe Mulet CLA 2006-06-21 06:24:35 EDT
Tempting for 3.2.1
Comment 4 Olivier Thomann CLA 2006-06-21 23:03:09 EDT
The problem comes from the method getUnqualifiedMethodHandle(...) in SourceMapper that doesn't recognize the signature of this method.
When the simple name is extracted, the + is not persisted. Then when the signature is rebuilt, it is considered to be invalid.
I'll investigate a fix.
Comment 5 Olivier Thomann CLA 2006-06-22 11:25:53 EDT
The method getUnqualifiedMethodHandle(IMethod, boolean) seems to be completely boggus. It doesn't handle well the type parameters that could be nested and the usage of nested types. See the first result below.

Here is some output of the qualified name, simple name and resulting unqualified name. Note that some identical entries for the qualified name and the simple name don't result in the same unqualified name.

---------------------------------------------------------
Qualified name = Ljava.util.Map$Entry<TK;TV;>;
Simple name = Map$Entry<TK;TV;>;
Unqualified name = QMap$Entry<QK;QV;>;
---------------------------------------------------------
Qualified name = Ljava.util.Map$Entry<TK;TV;>;
Simple name = Map$Entry<TK;TV;>;
Unqualified name = QEntry<QK;QV;>;
---------------------------------------------------------
Qualified name = Ljava.util.Collection<+Ljava.util.Map$Entry<TK;TV;>;>;
Simple name = Collection<Map$Entry<TK;TV;>;>;
Unqualified name = QCollection<Map$Entry<QK;QV;>;>;
---------------------------------------------------------
Qualified name = Ljava.util.Collection<+Ljava.util.Map$Entry<TK;TV;>;>;
Simple name = Collection<Map$Entry<TK;TV;>;>;
Unqualified name = QEntry<QK;QV;>;>;

or:
Qualified name = Ljava.util.List<+Ljava.lang.Comparable<-TT;>;>;
Simple name = List<Comparable<-TT;>;>;
Unqualified name = QList<Comparable<-QT;>;>;

for the method referenced in this PR.
Note the missing Q in the unqualified name. If the result would be:
Unqualified name = QList<+QComparable<-QT;>;>;
Then it would find the source range of the method.
Comment 6 Olivier Thomann CLA 2006-06-26 15:52:48 EDT
Created attachment 45322 [details]
Proposed fix

Jérôme,
Could you please review it?
Comment 7 Olivier Thomann CLA 2006-06-26 15:59:45 EDT
Created attachment 45324 [details]
Regression test

Regression test for simple name signature.
Comment 8 Jerome Lanneluc CLA 2006-06-27 06:51:07 EDT
In Signature#appendSimpleName(...), shouldn't the code be:
  if (name[start] == C_EXTENDS || name[start] == C_C_SUPER) {
    buffer.append(name[start]);
  }
instead of
  if (name[start] == C_EXTENDS || name[start] == C_EXTENDS) {
    buffer.append(name[start]);
  }
?

Otherwise the patch looks good.
Comment 9 Olivier Thomann CLA 2006-06-27 11:26:28 EDT
Yes, my mistake. This is why it is good to have a review :-).
I'll fix it and release it in HEAD.
So Philippe, do you want it for 3.2.1 or I leave it there only for 3.3?
Comment 10 Olivier Thomann CLA 2006-06-27 13:17:53 EDT
Fixed and released in HEAD.
Regression test added in org.eclipse.jdt.core.tests.model.SignatureTests.testGetSimpleName
Comment 11 Philipe Mulet CLA 2006-06-27 18:37:01 EDT
If the fix is safe, I think we should put it in 3.2.1 as well, since it hurts when broken (many features are no longer performing).
Olivier is the broken scenario very rare or not ?
Comment 12 Jerome Lanneluc CLA 2006-06-28 10:42:20 EDT
*** Bug 88023 has been marked as a duplicate of this bug. ***
Comment 13 Olivier Thomann CLA 2006-06-28 11:07:44 EDT
Released for 3.3 M1.
I don't think the fix is risky. Jérôme, any thoughts on this?
With the usage of generics, this case might not be rare (usage of wildcard is required however).
Comment 14 Jerome Lanneluc CLA 2006-06-28 11:19:32 EDT
Agree to backport the fix to 3.2.1
Comment 15 Philipe Mulet CLA 2006-06-28 12:06:36 EDT
+1 for 3.2.1
Comment 16 Frederic Fusier CLA 2006-08-08 04:34:58 EDT
Verified for 3.3 M1 using build I20060807-2000.

Not clear if this bug is a duplicate of bug 100093 or bug 129317 or if this is a separated issue... Looking at bug description I would expect a duplicate but it seems that there was a specific fix, perhaps any redondant changes in the code?

I think it should be revewied carefully for 3.2.1...
Comment 17 Philipe Mulet CLA 2006-09-06 06:02:24 EDT
reopening as not yet fixed in 3.2.1 target
Comment 18 Olivier Thomann CLA 2006-09-06 11:40:57 EDT
Released for 3.2.1.
Regression test added in
org.eclipse.jdt.core.tests.model.SignatureTests.testGetSimpleName
Comment 19 David Audel CLA 2006-09-12 04:57:13 EDT
Verified for 3.2.1 using build M20060908-1655
Comment 20 Markus Keller CLA 2006-09-13 05:03:48 EDT
*** Bug 157081 has been marked as a duplicate of this bug. ***