Some Eclipse Foundation services are deprecated, or will be soon. Please ensure you've read this important communication.

Bug 334268

Summary: [call hierarchy] doesn't recognize calls to method using varargs
Product: [Eclipse Project] JDT Reporter: Raffi Khatchadourian <raffi.khatchadourian>
Component: UIAssignee: JDT-UI-Inbox <jdt-ui-inbox>
Status: RESOLVED WORKSFORME QA Contact:
Severity: normal    
Priority: P3 CC: amj87.iitr, daniel_megert, deepakazad, raffi.khatchadourian
Version: 3.3.2   
Target Milestone: ---   
Hardware: All   
OS: Mac OS X - Carbon (unsup.)   
Whiteboard:

Description Raffi Khatchadourian CLA 2011-01-13 10:25:50 EST
Build Identifier: 20100917-0705

I have a method that uses varargs in its parameter list and I have a client method that calls it. When I run the call hierarchy on the method with the varargs, it displays that no methods call it.

Reproducible: Always

Steps to Reproduce:
1. Create a method with varargs.
2. Create a client method that calls the method from (1).
3. Run the call hierarchy tool on the method from (2).
Comment 1 Ayushman Jain CLA 2011-01-13 12:37:36 EST
Moving to JDT/UI.
Comment 2 Deepak Azad CLA 2011-01-13 21:11:42 EST
Sorry, I cannot reproduce this. Please provide a code snippet to reproduce the problem.
Comment 3 Dani Megert CLA 2011-01-14 03:26:01 EST
> Sorry, I cannot reproduce this. 
Same here using N20110113-2000.
Comment 4 Raffi Khatchadourian CLA 2011-01-14 10:16:22 EST
(In reply to comment #2)
> Sorry, I cannot reproduce this. Please provide a code snippet to reproduce the
> problem.

Sure. Here is the method with the varargs:

//AJUtil.java
public static void removeShadowsCorrespondingTo(Set<IJavaElement> addedShadowCol,
			JoinPointType... joinPointTypesToRemove) {
	//...
	}

When I construct the call hierarchy for this method, I receive to callers. However, the following method calls this method:

public void run(IAction action) {
//...
		AJUtil.removeShadowsCorrespondingTo(addedShadowCol, JoinPointType.FIELD_SET);
//...
}
Comment 5 Deepak Azad CLA 2011-01-14 10:43:24 EST
Nope, it works for me with the following code
-------------------------------------------------------------------------------
package snippet;

import java.util.HashSet;
import java.util.Set;

public class Snippet {

	public static void removeShadowsCorrespondingTo(Set<String> addedShadowCol,
			int... joinPointTypesToRemove) {
	}

	public void run() {
		Snippet.removeShadowsCorrespondingTo(new HashSet<String>(), new int[10]);
		Snippet.removeShadowsCorrespondingTo(new HashSet<String>(), 1,2,3,4);
	}
}
-------------------------------------------------------------------------------

Maybe you have another overloaded method? What happens when you select 'removeShadowsCorrespondingTo' here and press F3 (Open Declaration) ?

(In reply to comment #4)
> public void run(IAction action) {
> //...
>         AJUtil.removeShadowsCorrespondingTo(addedShadowCol,
> JoinPointType.FIELD_SET);
> //...
> }
Comment 6 Raffi Khatchadourian CLA 2011-01-14 10:54:54 EST
Funny enough, the F3 functionality works fine. In fact, when I build a call hierarchy on the client to show all outgoing method calls, again the removeShadows ... method doesn't show up.

I just tried your snippet and it works. There must be some other problem.

(In reply to comment #5)
> Nope, it works for me with the following code
> -------------------------------------------------------------------------------
> package snippet;
> 
> import java.util.HashSet;
> import java.util.Set;
> 
> public class Snippet {
> 
>     public static void removeShadowsCorrespondingTo(Set<String> addedShadowCol,
>             int... joinPointTypesToRemove) {
>     }
> 
>     public void run() {
>         Snippet.removeShadowsCorrespondingTo(new HashSet<String>(), new
> int[10]);
>         Snippet.removeShadowsCorrespondingTo(new HashSet<String>(), 1,2,3,4);
>     }
> }
> -------------------------------------------------------------------------------
> 
> Maybe you have another overloaded method? What happens when you select
> 'removeShadowsCorrespondingTo' here and press F3 (Open Declaration) ?
> 
> (In reply to comment #4)
> > public void run(IAction action) {
> > //...
> >         AJUtil.removeShadowsCorrespondingTo(addedShadowCol,
> > JoinPointType.FIELD_SET);
> > //...
> > }
Comment 7 Deepak Azad CLA 2011-01-14 12:04:52 EST
(In reply to comment #6)
> Funny enough, the F3 functionality works fine. In fact, when I build a call
> hierarchy on the client to show all outgoing method calls, again the
> removeShadows ... method doesn't show up.
> 
> I just tried your snippet and it works. There must be some other problem.
From the Call Hierarchy view menu double check the settings for 'Search In..', 'Search scope', 'Filters'.
Comment 8 Raffi Khatchadourian CLA 2011-01-14 14:58:07 EST
(In reply to comment #7)
> (In reply to comment #6)
> > Funny enough, the F3 functionality works fine. In fact, when I build a call
> > hierarchy on the client to show all outgoing method calls, again the
> > removeShadows ... method doesn't show up.
> > 
> > I just tried your snippet and it works. There must be some other problem.
> From the Call Hierarchy view menu double check the settings for 'Search In..',
> 'Search scope', 'Filters'.

Well, I feel idiotic now :). The search scope was only on project rather than workspace. Would it make sense to have the default set to workspace rather than project?
Comment 9 Deepak Azad CLA 2011-01-14 16:22:05 EST
(In reply to comment #8)
> Well, I feel idiotic now :). The search scope was only on project rather than
> workspace. Would it make sense to have the default set to workspace rather than
> project?
It happens :) Also the message at the top in the Call Hierarchy view is something like - "Members calling foo() - in workspace (no JRE)". This gives a clue about the current settings.