Community
Participate
Working Groups
If you have a project containing: /foo/bar/baz/blah/x.jar /foo/y/Y.java and do: javaProject.findPackageFragment(path) where path is the IPath to Y.java You get an IOOB from NameLookkup line 418. It's clear from the code in NameLookup that one of two things should be changed: either 1) line 414 should check not != 0 for matching segments but instead that rootPath is a *prefix* of path or 2) line 418 should not call rootPath.toOSString() but should instead use just the matching segments I think #2 is correct. Thanks.
*** Bug 202689 has been marked as a duplicate of this bug. ***
Can you please provide more detailed steps and the Eclipse build id?
Ok. More detailed: 1. Create a java project. 2. Create a class in package foo.y called Y -- this will give you a file /foo/y/Y.java 3. Pick your favorite jar file and copy it to /foo/bar/baz/blah/JARNAME.jar -- the jar file should live in the same folder structure as Y.java 4. Add the jar file to the project build path. 5. Save this project for later. Now, in your Eclipse plugin, write some code: IFile file = THE_IFILE_FOR_Y_DOT_JAVA_IN_THAT_PROJECT; IPath path = file.getLocation(); IJavaProject project = JavaCore.create(file.getProject()); project.findPackageFragment(path); // throws IOOB as described I am 99% certain that the fix is to change line 418 of NameLookup.java to use only the matching segments and not the whole .toOSString(). The reason this has not been found sooner is that jars are not usually stored in that sort of location. This happens with Eclipse 3.4.XXX for all XXX.
(In reply to comment #3) > 1. Create a java project. > 2. Create a class in package foo.y called Y > -- this will give you a file /foo/y/Y.java > 3. Pick your favorite jar file and copy it to /foo/bar/baz/blah/JARNAME.jar > -- the jar file should live in the same folder structure as Y.java > 4. Add the jar file to the project build path. > 5. Save this project for later. > > > Now, in your Eclipse plugin, write some code: > > IFile file = THE_IFILE_FOR_Y_DOT_JAVA_IN_THAT_PROJECT; > IPath path = file.getLocation(); > IJavaProject project = JavaCore.create(file.getProject()); > > project.findPackageFragment(path); // throws IOOB as described This still doesn't throw an IOOB for me but this returns null as expected (since the given path is the path to the Y.java file, it is not the path to the package fragment).
Created attachment 113451 [details] Corresponding test
Jay, please investigate. If it cannot be reproduced, please close as WORKSFORME.
Can't reproduce this on HEAD. Closing as WORKSFORME