Skip to main content

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

Hi Alexander,

I believe this is working as intended. Please refer to org.eclipse.jdt.core.JavaCore.newLibraryEntry(...) for more details.

Regards,
Jay



From:        Alexander Shutyaev <shutyaev@xxxxxxxxx>
To:        jdt-core-dev@xxxxxxxxxxx
Date:        09/18/2014 01:12 AM
Subject:        [jdt-core-dev] ClasspathEntry.getPath() returns wrong absolute        paths for simple jars
Sent by:        jdt-core-dev-bounces@xxxxxxxxxxx




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?_______________________________________________
jdt-core-dev mailing list
jdt-core-dev@xxxxxxxxxxx
To change your delivery options, retrieve your password, or unsubscribe from this list, visit
https://dev.eclipse.org/mailman/listinfo/jdt-core-dev

Back to the top