Bug 541636 - Program%20Files ... tools.jar which is referenced by the
classpath, does not exist
Applied same solution as for bug 470390.
Change-Id: I77ddd238cfc112c6288dfa02d2c741ad53dabe72
Signed-off-by: Andrey Loskutov <loskutov@gmx.de>
diff --git a/ant/org.eclipse.ant.launching/src/org/eclipse/ant/internal/launching/launchConfigurations/ContributedClasspathEntriesEntry.java b/ant/org.eclipse.ant.launching/src/org/eclipse/ant/internal/launching/launchConfigurations/ContributedClasspathEntriesEntry.java
index dd31631..6e109c7 100644
--- a/ant/org.eclipse.ant.launching/src/org/eclipse/ant/internal/launching/launchConfigurations/ContributedClasspathEntriesEntry.java
+++ b/ant/org.eclipse.ant.launching/src/org/eclipse/ant/internal/launching/launchConfigurations/ContributedClasspathEntriesEntry.java
@@ -156,17 +156,15 @@
if (install != null) {
IAntClasspathEntry entry = AntCorePlugin.getPlugin().getPreferences().getToolsJarEntry(new Path(install.getInstallLocation().getAbsolutePath()));
if (entry != null) {
- String pathString = null;
try {
- pathString = URIUtil.toURL(URIUtil.toURI(entry.getEntryURL())).getPath();
- rtes.add(JavaRuntime.newArchiveRuntimeClasspathEntry(new Path(pathString)));
+ URL entryURL = entry.getEntryURL();
+ String pathString = resolveFileFromUrl(entryURL.getFile());
+ if (!pathString.isEmpty()) {
+ rtes.add(JavaRuntime.newArchiveRuntimeClasspathEntry(new Path(pathString)));
+ }
}
catch (MalformedURLException e) {
AntLaunching.log(e);
-
- }
- catch (URISyntaxException e) {
- AntLaunching.log(e);
}
}
}
@@ -194,27 +192,12 @@
continue;
}
String urlFileName = bundleURL.getFile();
- if (urlFileName.startsWith(IAntCoreConstants.FILE_PROTOCOL)) {
- try {
- try {
- URI uri = URIUtil.toURI(new URL(urlFileName));
- // fix bug 470390 using toFile() instead of toURL()
- urlFileName = URIUtil.toFile(uri).getAbsolutePath();
- }
- catch (URISyntaxException e) {
- AntLaunching.log(e);
- }
- if (urlFileName.endsWith("!/") || urlFileName.endsWith("!\\")) { //$NON-NLS-1$ //$NON-NLS-2$
- urlFileName = urlFileName.substring(0, urlFileName.length() - 2);
- }
- if (urlFileName.endsWith("!")) { //$NON-NLS-1$
- urlFileName = urlFileName.substring(0, urlFileName.length() - 1);
- }
- }
- catch (MalformedURLException e) {
- AntLaunching.log(e);
- continue;
- }
+ try {
+ urlFileName = resolveFileFromUrl(urlFileName);
+ }
+ catch (MalformedURLException e) {
+ AntLaunching.log(e);
+ continue;
}
IPath fragmentPath = new Path(urlFileName);
if (fragmentPath.getFileExtension() != null) { // JAR file
@@ -239,6 +222,27 @@
rtes.addAll(fgSWTEntries);
}
+ private String resolveFileFromUrl(String urlFileName) throws MalformedURLException {
+ if (!urlFileName.startsWith(IAntCoreConstants.FILE_PROTOCOL)) {
+ return urlFileName;
+ }
+ try {
+ URI uri = URIUtil.toURI(new URL(urlFileName));
+ // fix bug 470390 using toFile() instead of toURL()
+ urlFileName = URIUtil.toFile(uri).getAbsolutePath();
+ }
+ catch (URISyntaxException e) {
+ AntLaunching.log(e);
+ }
+ if (urlFileName.endsWith("!/") || urlFileName.endsWith("!\\")) { //$NON-NLS-1$ //$NON-NLS-2$
+ urlFileName = urlFileName.substring(0, urlFileName.length() - 2);
+ }
+ if (urlFileName.endsWith("!")) { //$NON-NLS-1$
+ urlFileName = urlFileName.substring(0, urlFileName.length() - 1);
+ }
+ return urlFileName;
+ }
+
/**
* Returns the tools.jar to use for this launch configuration, or <code>null</code> if none.
*