Community
Participate
Working Groups
Build id: I20090528-2000 Today, i selected a method name (in its declaration), and then from the popup menu, i launched a search for references in the project. I got the following exception. If i try again, i get it again. java.lang.NullPointerException at org.eclipse.jdt.internal.compiler.util.SimpleSet.add(SimpleSet.java:38) at org.eclipse.jdt.internal.core.search.IndexSelector.getFocusedElements(IndexSelector.java:126) at org.eclipse.jdt.internal.core.search.IndexSelector.canSeeFocus(IndexSelector.java:52) at org.eclipse.jdt.internal.core.search.matching.MatchLocator.workingCopiesThatCanSeeFocus(MatchLocator.java:216) at org.eclipse.jdt.internal.core.search.matching.MatchLocator.addWorkingCopies(MatchLocator.java:172) at org.eclipse.jdt.internal.core.search.BasicSearchEngine.findMatches(BasicSearchEngine.java:222) at org.eclipse.jdt.internal.core.search.BasicSearchEngine.search(BasicSearchEngine.java:507) at org.eclipse.jdt.core.search.SearchEngine.search(SearchEngine.java:551) at org.eclipse.jdt.internal.ui.search.JavaSearchQuery.run(JavaSearchQuery.java:144) at org.eclipse.search2.internal.ui.InternalSearchUI$InternalSearchJob.run(InternalSearchUI.java:91) at org.eclipse.core.internal.jobs.Worker.run(Worker.java:55)
Would it be possible to zip the project and attached it to the bug (if not too big or not containing confidential code)? If this is not possible, try to reproduce with a similar test case in a new workspace... TIA
I will try, but after restarting eclipse, everything is fine. My guess is that the indexer must "mix" same type from different project, since before searching the reference, i was working on a "clone" project, and then i decied to switch to the original project and then the bug happened. The steps were: create a patch from the clone project, apply to the original project, and close the clone project.
Were you editing the file where you selected the method and launched the search? (In reply to comment #2) > I will try, but after restarting eclipse, everything is fine. My guess is that > the indexer must "mix" same type from different project, since before searching > the reference, i was working on a "clone" project, and then i decied to switch > to the original project and then the bug happened. The steps were: create a > patch from the clone project, apply to the original project, and close the > clone project. > I guess that "clone" means copied (e.g. from copy/paste), am I right?
Yes i was editing the file. No "clone" mean a java project "synced" to the same CVS module, but on a branch instead of the HEAD.
(In reply to comment #4) > No "clone" mean a java project "synced" to the same CVS module, but on a branch > instead of the HEAD. > So, you didn't have the project and its clone in the same workspace, did you?
(In reply to comment #5) > So, you didn't have the project and its clone in the same workspace, did you? Yes i had.
(In reply to comment #6) > (In reply to comment #5) > > So, you didn't have the project and its clone in the same workspace, did you? > > Yes i had. > Not sure to understand, then. How could you have two different branches of the same project in the same workspace as the project still has the same name...!? The standard UI to import project from CVS would not allow you to do this. Instead, it replaces the existing version with the other one... So, did you rename one of the branch of the project or did you use other special features I'm not aware of?
(In reply to comment #7) > Not sure to understand, then. How could you have two different branches of the > same project in the same workspace as the project still has the same name...!? > The standard UI to import project from CVS would not allow you to do this. > Instead, it replaces the existing version with the other one... So, did you > rename one of the branch of the project or did you use other special features > I'm not aware of? The project has not the same name. I create the project with a different name, and then do "Checkout as..." in existing project.
(In reply to comment #8) > The project has not the same name. I create the project with a different name, > and then do "Checkout as..." in existing project. > OK, thanks 2 other questions: 1) could you reproduce the NPE if you edit again the file, modify it to make it "dirty" and re-launched the search one the same selected method? 2) Are there compiler/builder errors in your workspace (typically problems with projects classpath)?
(In reply to comment #9) > 2 other questions: > 1) could you reproduce the NPE if you edit again the file, modify it to make it > "dirty" and re-launched the search one the same selected method? nope, i try on the original file, and on the clone project, without any error > 2) Are there compiler/builder errors in your workspace (typically problems with > projects classpath)? yes there is a few compiler error on some other java project.
OK, thanks for your time. Unfortunately, it would be difficult to find a reproducible test case. Saying that, I looked at the code closely, and it's obvious that the getFocusedElements(...) method can have a null focusElement, hence explains the NPE you got...
Created attachment 139981 [details] Proposed patch Add a check before adding the focused element in the set. Also improve return when there's finally no focused elements...
Olivier, This is an unexpected NPE preventing user to perform basic search action, hence according to our process could be a candidate for 3.5.1. Could you please review the patch and let me know if you agree?
Note that the patch does not contain any test as I was not able to find one which reproduces the NPE... :-(
Patch is safe and simple. +1 for 3.5.1. A regression test would be welcome.
Released for 3.6M1 in HEAD stream. Unfortunately, as no reproducible test case was found, a code review will be necessary during milestones verification processes...
Released for 3.5.1 in R3_5_maintenance stream.
Verified for 3.6M1 using build I20090803-1300
Verified the code in 3.5.1 build M20090826-1100
Verified.