Community
Participate
Working Groups
The code that eventually calls NameLookup is trying to convert the IBinding of a PackageBindingNode to an IJavaElement using binding.getJavaElement. In this particular case, the call stack for the ASTVisitor that found this PackageBindingNode is: * CompilationUnit * ImportDeclaration * QualifiedName (com.example.foo.bar.AClass) * QualifiedName(com.example.foo.bar) * QualifiedName(com.example.foo) According to the javadoc for NameLookup.findPackageFragments(String, boolean, boolean), it should return the package fragments, or null if none are found. That said, it should never return an empty array. I've snipped some of the code out of the method. Object value = this.packageFragments.get(splittedName); // line 534 if (value == null) return null; if (value instanceof PackageFragmentRoot) { return new IPackageFragment[] {((PackageFragmentRoot) value).getPackageFragment(splittedName)}; } else { IPackageFragmentRoot[] roots = (IPackageFragmentRoot[]) value; IPackageFragment[] result = new IPackageFragment[roots.length]; // line 561 for (int i= 0; i < roots.length; i++) { result[i] = ((PackageFragmentRoot) roots[i]).getPackageFragment(splittedName); } return result; } Here's what happens when I call QualifiedName(com.example.foo).resolveBinding().getJavaElement(): value on line 534 is not null, but it's IPackageFragmentRoot[0]. result on line 561 is turned into IPackageFragment[0], which is returned, and invalid. Now, the entire project does not compile, so maybe that's a hint as to why I'm finding this problem. Dunno.
Incidentally, this results in org.eclipse.jdt.core.dom.PackageBinding.getJavaElement throwing an IndexOutOfBoundsException.
Please provide build ID, and exact steps to reproduce.
Not enough information. Closing as INVALID
Reopen to close as a dup of bug 247205.
*** This bug has been marked as a duplicate of bug 247205 ***
Remove target.
This is not a dup of bug 247205. This bug is about NameLookup.findPackageFragments(String, boolean, boolean) but bug 247205 is about NameLookup.findPackageFragment(IPath). Closing again as INVALID since not enough information (especially build number) was provided to understand the issue.
Verified for 3.5M3 using I20081026-2000 build.