Browse Source

Generate proper file URLs in AntClassLoader#getResource, PR: 28060

git-svn-id: https://svn.apache.org/repos/asf/ant/core/trunk@276354 13f79535-47bb-0310-9956-ffa450edef68
master
Stefan Bodewig 21 years ago
parent
commit
55c133cecd
2 changed files with 8 additions and 2 deletions
  1. +3
    -0
      WHATSNEW
  2. +5
    -2
      src/main/org/apache/tools/ant/AntClassLoader.java

+ 3
- 0
WHATSNEW View File

@@ -119,6 +119,9 @@ Fixed bugs:


* <junit> and <assertions> are working together. Bugzilla report 27218 * <junit> and <assertions> are working together. Bugzilla report 27218


* AntClassLoader#getResource could return invalid URLs. Bugzilla
Report 28060.

Other changes: Other changes:
-------------- --------------




+ 5
- 2
src/main/org/apache/tools/ant/AntClassLoader.java View File

@@ -32,6 +32,7 @@ import java.util.Vector;
import java.util.zip.ZipEntry; import java.util.zip.ZipEntry;
import java.util.zip.ZipFile; import java.util.zip.ZipFile;
import org.apache.tools.ant.types.Path; import org.apache.tools.ant.types.Path;
import org.apache.tools.ant.util.FileUtils;
import org.apache.tools.ant.util.JavaEnvUtils; import org.apache.tools.ant.util.JavaEnvUtils;
import org.apache.tools.ant.util.LoaderUtils; import org.apache.tools.ant.util.LoaderUtils;


@@ -45,6 +46,8 @@ import org.apache.tools.ant.util.LoaderUtils;
*/ */
public class AntClassLoader extends ClassLoader implements BuildListener { public class AntClassLoader extends ClassLoader implements BuildListener {


private static final FileUtils fileUtils = FileUtils.newFileUtils();

/** /**
* An enumeration of all resources of a given name found within the * An enumeration of all resources of a given name found within the
* classpath of this class loader. This enumeration is used by the * classpath of this class loader. This enumeration is used by the
@@ -888,7 +891,7 @@ public class AntClassLoader extends ClassLoader implements BuildListener {


if (resource.exists()) { if (resource.exists()) {
try { try {
return new URL("file:" + resource.toString());
return fileUtils.getFileURL(resource);
} catch (MalformedURLException ex) { } catch (MalformedURLException ex) {
return null; return null;
} }
@@ -903,7 +906,7 @@ public class AntClassLoader extends ClassLoader implements BuildListener {
ZipEntry entry = zipFile.getEntry(resourceName); ZipEntry entry = zipFile.getEntry(resourceName);
if (entry != null) { if (entry != null) {
try { try {
return new URL("jar:file:" + file.toString()
return new URL("jar:" + fileUtils.getFileURL(file)
+ "!/" + entry); + "!/" + entry);
} catch (MalformedURLException ex) { } catch (MalformedURLException ex) {
return null; return null;


Loading…
Cancel
Save