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.
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);
doRefactoring on "where used" does not make sense. Your usages are in Collection "result" after call of wu.prepare(result)
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().
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.
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.
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
Created attachment 15697 [details] NPE when invoking Find USages on println
Increasing to P2, as NPE blocks P2 Issue 44570
Pavle, you forgot to increase a priority ;-)
NPE already fixed. I'll take a look at foo("bubu");
*** Issue 44916 has been marked as a duplicate of this issue. ***
Moved to new subcomponent java/javacore.
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.
Your thoughts are bad. Look at the class java.lang.System. Try to find 'out' field next time.
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
verified
Reorganization of java component