diff --git a/ui/org.eclipse.pde.core/src/org/eclipse/pde/internal/core/util/PDEJavaHelper.java b/ui/org.eclipse.pde.core/src/org/eclipse/pde/internal/core/util/PDEJavaHelper.java index 7818247653c..de7c880bf6f 100644 --- a/ui/org.eclipse.pde.core/src/org/eclipse/pde/internal/core/util/PDEJavaHelper.java +++ b/ui/org.eclipse.pde.core/src/org/eclipse/pde/internal/core/util/PDEJavaHelper.java @@ -19,6 +19,7 @@ import java.util.HashMap; import java.util.LinkedHashMap; import java.util.ListIterator; +import java.util.Map; import org.eclipse.core.resources.IProject; import org.eclipse.core.resources.IResource; @@ -286,9 +287,16 @@ private static IPackageFragment searchWorkspaceForPackage(String packageName, IP continue; } IJavaProject jp = JavaCore.create(projects[i]); + Map rootsByPath = new HashMap<>(); + for (IPackageFragmentRoot classpathRoot : jp.getAllPackageFragmentRoots()) { + IPath classRootPath = classpathRoot.getPath(); + if (classRootPath != null) { + rootsByPath.put(classRootPath, classpathRoot); + } + } ListIterator li = libPaths.listIterator(); while (li.hasNext()) { - IPackageFragmentRoot root = jp.findPackageFragmentRoot(li.next()); + IPackageFragmentRoot root = rootsByPath.get(li.next()); if (root != null) { IPackageFragment frag = root.getPackageFragment(packageName); if (frag.exists()) {