Bug 21485 - NPE when doing a reference search to a package
Summary: NPE when doing a reference search to a package
Status: VERIFIED FIXED
Alias: None
Product: JDT
Classification: Eclipse Project
Component: Core (show other bugs)
Version: 2.0   Edit
Hardware: PC Windows 2000
: P3 normal (vote)
Target Milestone: 2.1 M1   Edit
Assignee: Jerome Lanneluc CLA
QA Contact:
URL:
Whiteboard:
Keywords:
: 22946 (view as bug list)
Depends on:
Blocks:
 
Reported: 2002-07-11 10:06 EDT by Erich Gamma CLA
Modified: 2002-09-18 12:09 EDT (History)
2 users (show)

See Also:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Erich Gamma CLA 2002-07-11 10:06:44 EDT
I cannot reliably reproduce this. What I did was selecting a package and doing 
a reference search:

java.lang.reflect.InvocationTargetException: java.lang.NullPointerException
	at org.eclipse.jdt.internal.compiler.lookup.ReferenceBinding.canBeSeenBy
(ReferenceBinding.java(Compiled Code))
	at org.eclipse.jdt.internal.compiler.lookup.Scope.getTypeOrPackage
(Scope.java:955)
	at org.eclipse.jdt.internal.core.search.matching.MatchSet.reportMatching
(MatchSet.java:222)
	at 
org.eclipse.jdt.internal.core.search.matching.MatchingOpenable.locateMatchesInCo
mpilationUnit(MatchingOpenable.java:331)
	at 
org.eclipse.jdt.internal.core.search.matching.MatchingOpenable.locateMatches
(MatchingOpenable.java:174)
	at 
org.eclipse.jdt.internal.core.search.matching.MatchLocator.locateMatches
(MatchLocator.java:1323)
	at 
org.eclipse.jdt.internal.core.search.matching.MatchLocator.locateMatches
(MatchLocator.java:586)
	at org.eclipse.jdt.core.search.SearchEngine.search
(SearchEngine.java:412)
	at org.eclipse.jdt.core.search.SearchEngine.search
(SearchEngine.java:358)
	at org.eclipse.jdt.internal.ui.search.JavaSearchOperation.execute
(JavaSearchOperation.java:84)
	at org.eclipse.ui.actions.WorkspaceModifyOperation$1.run
(WorkspaceModifyOperation.java:64)
	at org.eclipse.core.internal.resources.Workspace.run
(Workspace.java:1361)
	at org.eclipse.ui.actions.WorkspaceModifyOperation.run
(WorkspaceModifyOperation.java:78)
	at org.eclipse.jface.operation.ModalContext$ModalContextThread.run
(ModalContext.java:98)
Comment 1 Philipe Mulet CLA 2002-07-24 12:55:31 EDT
Fix won't be ready for 2.0.1. Marking for 2.1 instead.
Comment 2 Simon Gunzenreiner CLA 2002-08-21 03:37:10 EDT
Got same exception when searching for references to a class "A", when the
reference of the referencing class ("B") is not valid (e.g. if "A" is not
visible to "B", but "B" imports it).
Comment 3 Jerome Lanneluc CLA 2002-08-22 05:45:51 EDT
Was able to reproduce as follow:
1. Create package p1
2. Create class A in p1:
package p1;
class A {
}
3. Create package p2
4. Create class B in p2
package p2;
import p1.A;
public class B extends A {
}
5. Searching for reference to class A or to package p1 produces the above stack 
trace.

Thanks for the test case Simon.
Comment 4 Jerome Lanneluc CLA 2002-08-22 06:41:49 EDT
Fixed Scope.getTypeOrPackage(char[]) so that is doesn't check the visibility if 
the scope is a CompilationUnitScope (canBeSeenBy(Scope) doesn't support such a 
scope).
Comment 5 Jerome Lanneluc CLA 2002-08-29 05:44:21 EDT
*** Bug 22946 has been marked as a duplicate of this bug. ***
Comment 6 Adam Kiezun CLA 2002-08-30 09:49:32 EDT
for a real-life example - search for references to the class
org.eclipse.jdt.internal.corext.dom.ASTFlattener 
Comment 7 Jerome Lanneluc CLA 2002-08-30 10:54:54 EDT
This works for me in 2.0 (so is life real? :-)
Of course you don't have the fix yet... (since there was no build contribution 
from JDT/Core for the last integration build)
Comment 8 Jerome Lanneluc CLA 2002-09-02 06:43:02 EDT
Fix was not good enough (other senders of canBeSeenBy may have the same 
problem).
So changed canBeSeenBy to handle the case of a compilation unit scope and 
removed change in Scope.getTypeOrPackage(char[]).
Comment 9 David Audel CLA 2002-09-18 12:09:58 EDT
Verified.