This Bugzilla instance is a read-only archive of historic NetBeans bug reports. To report a bug in NetBeans please follow the project's instructions for reporting issues.

Bug 43896 - Where Used doesn't work on overloaded methods. Methods are not resolved correctly.
Summary: Where Used doesn't work on overloaded methods. Methods are not resolved corre...
Status: CLOSED FIXED
Alias: None
Product: java
Classification: Unclassified
Component: Unsupported (show other bugs)
Version: 4.x
Hardware: PC Linux
: P2 blocker (vote)
Assignee: Tomas Hurka
URL:
Keywords:
: 44916 (view as bug list)
Depends on:
Blocks: 44570
  Show dependency tree
 
Reported: 2004-05-26 15:33 UTC by ehucka
Modified: 2007-09-26 09:14 UTC (History)
1 user (show)

See Also:
Issue Type: DEFECT
Exception Reporter:


Attachments
NPE when invoking Find USages on println (3.25 KB, text/plain)
2004-06-15 12:34 UTC, psuk
Details

Note You need to log in before you can comment on or make changes to this bug.
Description ehucka 2004-05-26 15:33:32 UTC
I've tried to invoke WhereUsed refactoring on a
method of JDK class. Refactoring found nothing.

I'm using code like this:

ArrayList list=new ArrayList();
jc = (JavaClass) findClass("java.io.PrintStream");
typeProxy = ((JavaModelPackage)
jc.refOutermostPackage()).getType();
list.add(typeProxy.resolve("java.lang.String"));
method = jc.getMethod("println", list, true);
wu=new
org.netbeans.api.refactoring.WhereUsedQuery(method);
result = new ArrayList();
wu.prepare(result);
support.doRefactoring(result, "Where's Method", null);
Comment 1 Jan Becicka 2004-05-26 15:42:11 UTC
doRefactoring on "where used" does not make sense.

Your usages are in Collection "result" after call of wu.prepare(result)



Comment 2 ehucka 2004-05-26 16:18:05 UTC
I think, doRefactoring on WhereUsed do nothing (doesn't remove items
from result collection). I commented it and it still doesn't work.
Try to call Where used refactoring on println(String) method in
java/io/PrintStream.java by IDE. It will find only println().
Comment 3 Tomas Hurka 2004-05-27 09:37:57 UTC
Partially fixed. 
Checking in org/netbeans/modules/javacore/parser/MDRParser.java;
/cvs/java/javacore/src/org/netbeans/modules/javacore/parser/Attic/MDRParser.java,v  
<--  MDRParser.java
new revision: 1.1.2.70.2.36; previous revision: 1.1.2.70.2.35
done

println() still does not work, but other methods, which can be distinguished by name and 
number of parameters works OK.
Comment 4 Martin Matula 2004-05-28 18:10:29 UTC
This is not related to JDK. The general problem is that the resolution
of methods is not accurate currently, since it does not consider
parameter types. Thus if there are several methods with the same name
and same number of parameters, the method resolution likely fails.
Comment 5 psuk 2004-06-15 12:31:50 UTC
Example [dev 040615]:

public void foo(int i){}
public void foo(String s){}
    
    public void test1() {
        foo(2);
        foo("bubu");
        System.out.println();
        System.out.println("dsds");        
    }

1. Find Usages on foo(int i) returns both occurences.
2. Find Usages on println causes NPE
   
Comment 6 psuk 2004-06-15 12:34:23 UTC
Created attachment 15697 [details]
NPE when invoking Find USages on println
Comment 7 psuk 2004-06-15 12:44:39 UTC
Increasing to P2, as NPE blocks P2 Issue 44570
Comment 8 Marek Grummich 2004-06-15 12:54:29 UTC
Pavle, you forgot to increase a priority ;-)
Comment 9 Jan Becicka 2004-06-15 13:06:10 UTC
NPE already fixed.
I'll take a look at foo("bubu");
Comment 10 Jan Becicka 2004-06-16 07:45:52 UTC
*** Issue 44916 has been marked as a duplicate of this issue. ***
Comment 11 Tomas Hurka 2004-06-22 08:42:02 UTC
Moved to new subcomponent java/javacore.
Comment 12 ehucka 2004-06-30 14:31:58 UTC
I think there is another problem.

I have a project where I frequently use System.out.println(...). If I
go to println (in System.out.println) and invoke Find usages, it will
find all "System.out.printlns". It founds code like: PrintStream ps;
ps.println(...); too.
But when I open a source of java.io.PrintStream in editor and invoke
Find usages on println(String) or println(Object), nothing will be found.
Comment 13 Pavel Flaska 2004-06-30 14:38:52 UTC
Your thoughts are bad. Look at the class java.lang.System. Try to find
'out' field next time.
Comment 14 Tomas Hurka 2004-07-01 17:06:30 UTC
Fixed in trunk. 
Resolution of methods now considers parameter types and access modifiers.

Checking in parser/MDRParser.java;
/cvs/java/javacore/src/org/netbeans/modules/javacore/parser/MDRParser.java,v  <--  
MDRParser.java
new revision: 1.26; previous revision: 1.25
done
RCS file: /cvs/java/javacore/src/org/netbeans/modules/javacore/parser/
MethodScope.java,v
done
Checking in parser/MethodScope.java;
/cvs/java/javacore/src/org/netbeans/modules/javacore/parser/MethodScope.java,v  <--  
MethodScope.java
initial revision: 1.1
done
RCS file: /cvs/java/javacore/src/org/netbeans/modules/javacore/parser/
MethodScopeMember.java,v
done
Checking in parser/MethodScopeMember.java;
/cvs/java/javacore/src/org/netbeans/modules/javacore/parser/
MethodScopeMember.java,v  <--  MethodScopeMember.java
initial revision: 1.1
done
Checking in parser/Scope.java;
/cvs/java/javacore/src/org/netbeans/modules/javacore/parser/Scope.java,v  <--  
Scope.java
new revision: 1.8; previous revision: 1.7
done
Comment 15 ehucka 2004-08-17 16:31:23 UTC
verified
Comment 16 Quality Engineering 2007-09-20 12:19:57 UTC
Reorganization of java component