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

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

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.ZipFile;
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.LoaderUtils;

@@ -45,6 +46,8 @@ import org.apache.tools.ant.util.LoaderUtils;
*/
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
* 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()) {
try {
return new URL("file:" + resource.toString());
return fileUtils.getFileURL(resource);
} catch (MalformedURLException ex) {
return null;
}
@@ -903,7 +906,7 @@ public class AntClassLoader extends ClassLoader implements BuildListener {
ZipEntry entry = zipFile.getEntry(resourceName);
if (entry != null) {
try {
return new URL("jar:file:" + file.toString()
return new URL("jar:" + fileUtils.getFileURL(file)
+ "!/" + entry);
} catch (MalformedURLException ex) {
return null;


Loading…
Cancel
Save