Community
Participate
Working Groups
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)
Fix won't be ready for 2.0.1. Marking for 2.1 instead.
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).
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.
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).
*** Bug 22946 has been marked as a duplicate of this bug. ***
for a real-life example - search for references to the class org.eclipse.jdt.internal.corext.dom.ASTFlattener
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)
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[]).
Verified.