Community
Participate
Working Groups
Created attachment 87182 [details] Sample project on which I see this exception happen Build ID: I20071213-1700 Steps To Reproduce: I have the following code that uses JDT search APIs: SearchPattern pattern = null; for (int v=0;v<types.size();v++) { IType typ = types.get(v); SearchPattern pattern1 = SearchPattern.createPattern(typ, IJavaSearchConstants.REFERENCES); if(pattern!=null) { pattern = SearchPattern.createOrPattern(pattern, pattern1); } else { pattern = pattern1; } } if(pattern!=null) { try { searchEngine.search(pattern, participats, scope, requestor, null); } catch(Exception e) { e.printStackTrace(); } return requestor.getResults(); } The basic idea behind my code, is that I have a number of IType objects (which represent Annotation types) and I want find references to these objects. Participats and requestor are very simple. When this code is ran I get the following exception: java.lang.NullPointerException at org.eclipse.jdt.internal.compiler.lookup.BinaryTypeBinding.availableMethods(BinaryTypeBinding.java:235) at org.eclipse.jdt.internal.core.search.matching.ClassFileMatchLocator.locateMatches(ClassFileMatchLocator.java:185) at org.eclipse.jdt.internal.core.search.matching.MatchLocator.process(MatchLocator.java:1516) at org.eclipse.jdt.internal.core.search.matching.MatchLocator.locateMatches(MatchLocator.java:1027) at org.eclipse.jdt.internal.core.search.matching.MatchLocator.locateMatches(MatchLocator.java:1068) at org.eclipse.jdt.internal.core.search.matching.MatchLocator.locateMatches(MatchLocator.java:1190) at org.eclipse.jdt.internal.core.search.JavaSearchParticipant.locateMatches(JavaSearchParticipant.java:94) at org.eclipse.jdt.internal.core.search.BasicSearchEngine.findMatches(BasicSearchEngine.java:217) at org.eclipse.jdt.internal.core.search.BasicSearchEngine.search(BasicSearchEngine.java:500) at org.eclipse.jdt.core.search.SearchEngine.search(SearchEngine.java:550) More information:
Please provide the entire code to make it easier to reproduce, thanks
Created attachment 87893 [details] Class where I invoke search API
Created attachment 87894 [details] Requestor1
Created attachment 87895 [details] Requestor2
Please see provided attachements to see my code. Please let me know if you any additional info.
I cannot reproduce the NPE using the given sample project + search and requestors snippets... Note that using Search fine grain will solve the problem in a faster way (around 3 times faster): private Set findAnnotationReferences(IJavaElement javaElement) { IJavaSearchScope scope = SearchEngine.createJavaSearchScope(new IJavaElement[] { javaElement }); SearchAllAnnotationsReferencesRequestor requestor = new SearchAllAnnotationsReferencesRequestor(); SearchPattern pattern = SearchPattern.createPattern("*", IJavaSearchConstants.ANNOTATION_TYPE, IJavaSearchConstants.ANNOTATION_TYPE_REFERENCE, SearchPattern.R_PATTERN_MATCH); //$NON-NLS-1$ try { new SearchEngine().search(pattern, new SearchParticipant[] { SearchEngine.getDefaultSearchParticipant() }, scope, requestor, null); } catch (Exception e) { e.printStackTrace(); } return requestor.results; } class SearchAllAnnotationsReferencesRequestor extends SearchRequestor { Set results = new HashSet(); public void acceptSearchMatch(SearchMatch match) throws CoreException { this.results.add(match.getElement()); } }
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.