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

Bug 404135

Summary: NPE during Java Search
Product: [Eclipse Project] JDT Reporter: Gary Karasiuk <gary>
Component: CoreAssignee: JDT-Core-Inbox <jdt-core-inbox>
Status: CLOSED WONTFIX QA Contact:
Severity: normal    
Priority: P3 CC: fheathrenn+uk, jarthana, jvines, stephan.herrmann
Version: 4.2.2   
Target Milestone: ---   
Hardware: PC   
OS: Mac OS X   
Whiteboard: stalebug

Description Gary Karasiuk CLA 2013-03-22 09:05:25 EDT
When doing a search on a particular method (Command-Shift-G) I always get this NPE. 

I did a project clean all and restarted my workbench, but the error persists.


java.lang.NullPointerException
	at org.eclipse.jdt.internal.core.search.matching.ClasspathSourceDirectory.directoryTable(ClasspathSourceDirectory.java:44)
	at org.eclipse.jdt.internal.core.search.matching.ClasspathSourceDirectory.findClass(ClasspathSourceDirectory.java:84)
	at org.eclipse.jdt.internal.core.search.matching.JavaSearchNameEnvironment.findClass(JavaSearchNameEnvironment.java:146)
	at org.eclipse.jdt.internal.core.search.matching.JavaSearchNameEnvironment.findType(JavaSearchNameEnvironment.java:185)
	at org.eclipse.jdt.internal.compiler.lookup.LookupEnvironment.askForType(LookupEnvironment.java:145)
	at org.eclipse.jdt.internal.compiler.lookup.PackageBinding.getTypeOrPackage(PackageBinding.java:197)
	at org.eclipse.jdt.internal.compiler.lookup.Scope.getTypeOrPackage(Scope.java:2795)
	at org.eclipse.jdt.internal.compiler.lookup.Scope.getType(Scope.java:2513)
	at org.eclipse.jdt.internal.core.search.matching.MatchLocator.getType(MatchLocator.java:899)
	at org.eclipse.jdt.internal.core.search.matching.MatchLocator.getMethodBinding0(MatchLocator.java:955)
	at org.eclipse.jdt.internal.core.search.matching.MatchLocator.getMethodBinding(MatchLocator.java:907)
	at org.eclipse.jdt.internal.core.search.matching.MethodLocator.matchMethod(MethodLocator.java:327)
	at org.eclipse.jdt.internal.core.search.matching.MethodLocator.resolveLevel(MethodLocator.java:664)
	at org.eclipse.jdt.internal.core.search.matching.ClassFileMatchLocator.locateMatches(ClassFileMatchLocator.java:209)
	at org.eclipse.jdt.internal.core.search.matching.MatchLocator.process(MatchLocator.java:1697)
	at org.eclipse.jdt.internal.core.search.matching.MatchLocator.locateMatches(MatchLocator.java:1141)
	at org.eclipse.jdt.internal.core.search.matching.MatchLocator.locateMatches(MatchLocator.java:1182)
	at org.eclipse.jdt.internal.core.search.matching.MatchLocator.locateMatches(MatchLocator.java:1299)
	at org.eclipse.jdt.internal.core.search.JavaSearchParticipant.locateMatches(JavaSearchParticipant.java:95)
	at org.eclipse.jdt.internal.core.search.BasicSearchEngine.findMatches(BasicSearchEngine.java:231)
	at org.eclipse.jdt.internal.core.search.BasicSearchEngine.search(BasicSearchEngine.java:515)
	at org.eclipse.jdt.core.search.SearchEngine.search(SearchEngine.java:584)
	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:53)
Comment 1 Gary Karasiuk CLA 2013-03-22 09:43:40 EDT
To jog my own memory, I searching on BooksUser.get()
Comment 2 Jay Arthanareeswaran CLA 2013-03-25 00:41:19 EDT
The symptoms look very similar to that of bug 402510.

Gary, can you please take a look at the bug 402510 and see if your environment is similar too?
Comment 3 Gary Karasiuk CLA 2013-03-25 06:38:56 EDT
(In reply to comment #2)
> The symptoms look very similar to that of bug 402510.
> 
> Gary, can you please take a look at the bug 402510 and see if your
> environment is similar too?

AFAIK my environment doesn't have anything to do with Groovy.

I am using the WTP distribution of Eclipse (i.e. Eclipse Java EE IDE for Web Developers), along with the GIT bundles. Here are my installation details:

  Eclipse EGit	2.2.0.201212191850-r	org.eclipse.egit.feature.group	Eclipse EGit
  Eclipse IDE for Java EE Developers	1.5.2.20130211-1820	epp.package.jee	null
Comment 4 John Vines CLA 2013-12-11 11:16:53 EST
I am also getting this error with 4.3.1. It only seems to be occuring when I do a reference search when I have closed working sets. When I open them all, the search waits a bit for everything to index, and then passes.
Comment 5 John Vines CLA 2013-12-11 11:18:42 EST
Additionally, the entry in my .metadata/.log is very sparse-

!ENTRY org.eclipse.core.jobs 4 2 2013-12-11 11:10:52.359
!MESSAGE An internal error occurred during: "Java Search".
!STACK 0
java.lang.NullPointerException

and that's it. No stack trace or anything.
Comment 6 Frederic Heath-Renn CLA 2015-01-15 05:47:52 EST
I am also getting this bug in a large project I am working on. It happens when I attempt to find references in the workspace for a function called Participant.create(Participant p). Like J Vines above, I get just "java.lang.NullPointerException" in the error log, with no other stack trace information present.

I don't know if it's just coincidence, but - if I right-click and refactor the function to Participant.createParticipant(Participant p) (which works just fine), I am then able to find references for it with no trouble at all. I am not sure why refactoring works but finding references doesn't, when presumably refactoring involves at some level finding references.
Comment 7 Stephan Herrmann CLA 2015-01-15 06:12:24 EST
This bug was originally reported against 4.2.2. The stack trace in comment 0 looks the same as bug 377883, which was fixed for 4.4.

Please everybody still seeing this problem please paste your version of JDT.
Comment 8 Eclipse Genie CLA 2020-03-31 13:30:41 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. As such, we're closing this bug.

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