Community
Participate
Working Groups
I try to find a package fragment using the Method IJavaProject.findPackageFragment(path). Calling this method on a project that contains JUnit with the argument "/junit/framework" returns null. Calling the method with the argument "junit/framework" (path isn't absolute) throws an AssertFailedException. How do I find a package fragment if I want to consider the project's class path. NOTES: OT (11/24/00 2:31:11 PM) Try this: IPackageFragment fragment = project.getNameLookup().findPackageFragment("junit.frameworkpath", false); DB (05.12.2000 10:31:39) The method getNameLookup isn't part of the IJavaProject interface so I am not able to use it. The implementation of JavaProject.findPackageFragement(path) does exactly what you propose so I think that this won't work either. public IPackageFragment findPackageFragment(IPath path) throws JavaModelException { return getNameLookup().findPackageFragment(path); } What is the path separator character I have to use? A '.' or a '/'? In general IPath is using '/'.
The IJavaProject specs says to use '/'/ /** * Returns the first existing package fragment on this project's classpath * whose path matches the given (absolute) path, or <code>null</code> if none * exist. * The path can be: * - internal to the workbench: "/Project/src" * - external to the workbench: "c:/jdk/classes.zip/java/lang" * * @exception JavaModelException if this element does not exist or if an * exception occurs while accessing its corresponding resource */ IPackageFragment findPackageFragment(IPath path) throws JavaModelException;
Closing
Why got this PR closed. Is it fixed now. The first comment states that neither /junit/framework not junit/framework works as a path. So I am already using the / character as a path separator.
The specs says how to use the API. You have to use a '/'. Looks in your case, you forgot the project prefix: '/JUnit/src/junit/framework'. Do I miss something ?
Yup, forgot to add /JUnit/src to the path. It is a little bit confusing that if I call the method on an IJavaProject which represents the JUnit project that I have to prepend the path with the /JUnit/src. PR can be closed.