Skip to main content

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] [List Home]
[jdt-core-dev] ClasspathEntry.getPath() returns wrong absolute paths for simple jars

Hi all,

I want to collect all classpath entries that my java project uses. For that I'm using

IClasspathEntry [] cpe = javaProject.getResolvedClasspath(false);
for (int i=0; i<cpe.length; i++) {
if (IClasspathEntry.CPE_LIBRARY == cpe[i].getEntryKind())
result.add(cpe[i].getPath().toOSString());
}
}

The javadoc of ClasspathEntry says that
  • A binary library in the current project, in another project, or in the external file system. In this case the entry identifies a JAR (or root folder) containing package fragments and .class files. The classpath entry must specify the absolute path to the JAR (or root folder), and in case it refers to an external JAR, then there is no associated resource in the workbench. Entries of this kind are associated with the CPE_LIBRARY constant.
However for a most simple library that I've added to .classpath as follows

<classpathentry kind="lib" path="lib/mylib.jar" />

the getPath() returns "/myproject/lib/mylib.jar" where myproject is my project's name. Moreover isAbsolute() method of this path returns true. However that is wrong because this path is really relative to my workspace's root.

On the other hand the JDK's jars (like rt.jar) are being returned correclty with a fully absolute path.

Is this the expected behavior? If no, should I report it in bugzilla? If it is expected behavior then what is the correct way to collect all jars with "real" absolute paths?

Back to the top