Bug 354603 - [search] Call hierarchy does not find some constructor calls
Summary: [search] Call hierarchy does not find some constructor calls
Status: CLOSED WONTFIX
Alias: None
Product: JDT
Classification: Eclipse Project
Component: Core (show other bugs)
Version: 3.8   Edit
Hardware: PC Linux
: P3 normal (vote)
Target Milestone: ---   Edit
Assignee: Stephan Herrmann CLA
QA Contact:
URL:
Whiteboard: stalebug
Keywords:
Depends on:
Blocks:
 
Reported: 2011-08-12 07:22 EDT by Michal Politowski CLA
Modified: 2019-10-10 17:02 EDT (History)
5 users (show)

See Also:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Michal Politowski CLA 2011-08-12 07:22:21 EDT
Build Identifier: 20110615-0604

When trying to open call hierarchy for the constructors of ThreadLocalMap,
the private ThreadLocalMap(ThreadLocalMap parentMap) constructor works as expected, but for the ThreadLocalMap(ThreadLocal firstKey, Object firstValue) constructor no callers are found.
Also for the constructor of ThreadLocalMap.Entry, which is called multiple times in ThreadLocalMap no callers are found by Open Call Hierarchy.

Reproducible: Always

Steps to Reproduce:
1. use Open Type to open ThreadLocalMap (from java.lang.ThreadLocal)
2. select the ThreadLocalMap(ThreadLocal firstKey, Object firstValue) constructor and run Open Call Hierarchy
3. in the call hierarchy view verify that no callers are found
Comment 1 Markus Keller CLA 2011-08-13 13:33:15 EDT
Search for references also fails. JDT UI doesn't get any search results.

AST and binding resolution look OK, since Mark Occurrences finds the references. However, IMethodBinding#getJavaElement() returns a wrongly inexistent element for these constructor bindings. The IMethod's parameter types seem to contain a "Ljava.lang.ThreadLocal<TT;>;" too much.
Comment 2 Stephan Herrmann CLA 2011-08-13 14:06:08 EDT
(In reply to comment #1)
> Search for references also fails. JDT UI doesn't get any search results.
> 
> AST and binding resolution look OK, since Mark Occurrences finds the
> references. However, IMethodBinding#getJavaElement() returns a wrongly
> inexistent element for these constructor bindings. The IMethod's parameter
> types seem to contain a "Ljava.lang.ThreadLocal<TT;>;" too much.

That first parameter is artfully crafted to match the binary signature,
where the enclosing instance is passed to the constructor via synth arg.

Let me see what else I can find..
Comment 3 Stephan Herrmann CLA 2011-08-13 15:34:40 EDT
(In reply to comment #2)
> Let me see what else I can find..

Lots of confusion regarding constructors of binary nested classes :-/

First I had to learn that BinaryMethod indeed reflects the signature
exactly as stored in the byte code, i.e., synthetic arguments are shown.

Second, ThreadLocalMap being a static nested class does not insert
synthetic arguments for its constructors.

Third,  org.eclipse.jdt.internal.core.util.Util.getUnresolvedJavaElement(MethodBinding, WorkingCopyOwner, BindingsToNodesMap)
adds a synthetic argument even for constructors of static nested classes.


Forth, ConstructorPattern(char[],char[],char[][],char[][],int,int)
uses a halfhearted heuristic to determine whether the first parameter
is such a synthetic one: "does the type match the enclosing class?"
I assume this is the root cause for this particular problem, because
ThreadLocal$ThreadLocalMap(ThreadLocal,Object) is an example of where
this heuristic fails. In bug 277669 comment 6 Olivier mentioned that the
current implementation fails for exactly one method in the whole JDK. 

Olivier, is this that one method??

Note that the related bug 275853 is still (or again) unresolved.
Comment 4 Stephan Herrmann CLA 2011-08-13 15:40:30 EDT
(In reply to comment #3)
> Forth, ConstructorPattern(char[],char[],char[][],char[][],int,int)
> uses a halfhearted heuristic to determine whether the first parameter
> is such a synthetic one: "does the type match the enclosing class?"

xref: this was introduced for bug 95152
Comment 5 Satyam Kandula CLA 2011-08-23 09:07:04 EDT
Stephan, Moving to you as you are working on it.
Comment 6 Eclipse Genie CLA 2019-10-10 17:02:55 EDT
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.

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