Browse Source

Work around a feature of the system classloader in some VMs - it

drops all classpath entries that are not present at VM start time.

PR: 2412


git-svn-id: https://svn.apache.org/repos/asf/ant/core/trunk@269271 13f79535-47bb-0310-9956-ffa450edef68
master
Stefan Bodewig 24 years ago
parent
commit
218ad5fc4d
3 changed files with 20 additions and 20 deletions
  1. +10
    -15
      src/main/org/apache/tools/ant/taskdefs/Definer.java
  2. +8
    -3
      src/main/org/apache/tools/ant/types/Path.java
  3. +2
    -2
      src/main/org/apache/tools/zip/ZipExtraField.java

+ 10
- 15
src/main/org/apache/tools/ant/taskdefs/Definer.java View File

@@ -97,25 +97,20 @@ public abstract class Definer extends Task {
}
try {
ClassLoader loader = null;
AntClassLoader al = null;
if (classpath != null) {
AntClassLoader al = new AntClassLoader(project, classpath,
false);
// need to load Task via system classloader or the new
// task we want to define will never be a Task but always
// be wrapped into a TaskAdapter.
al.addSystemPackageRoot("org.apache.tools.ant");
loader = al;
al = new AntClassLoader(project, classpath, false);
} else {
loader = this.getClass().getClassLoader();
al = new AntClassLoader(project, Path.systemClasspath, false);
}
// need to load Task via system classloader or the new
// task we want to define will never be a Task but always
// be wrapped into a TaskAdapter.
al.addSystemPackageRoot("org.apache.tools.ant");
loader = al;

Class c = null;
if (loader != null) {
c = loader.loadClass(value);
AntClassLoader.initializeClass(c);
} else {
c = Class.forName(value);
}
Class c = loader.loadClass(value);
AntClassLoader.initializeClass(c);
addDefinition(name, c);
} catch (ClassNotFoundException cnfe) {
String msg = getTaskName()+" class " + value +


+ 8
- 3
src/main/org/apache/tools/ant/types/Path.java View File

@@ -484,9 +484,14 @@ public class Path extends DataType implements Cloneable {

Path result = new Path(project);

String order = project.getProperty("build.sysclasspath");
if (order == null) order=defValue;

String order = defValue;
if (project != null) {
String o = project.getProperty("build.sysclasspath");
if (o != null) {
order = o;
}
}
if (order.equals("only")) {
// only: the developer knows what (s)he is doing
result.addExisting(Path.systemClasspath);


+ 2
- 2
src/main/org/apache/tools/zip/ZipExtraField.java View File

@@ -59,11 +59,11 @@ import java.util.zip.ZipException;
/**
* General format of extra field data.
*
* <p>Extra fields usually apper twice per file, once in the local
* <p>Extra fields usually appear twice per file, once in the local
* file data and once in the central directory. Usually they are the
* same, but they don't have to be. {@link
* java.util.zip.ZipOutputStream java.util.zip.ZipOutputStream} will
* only use write the local file data at both places.</p>
* only use the local file data in both places.</p>
*
* @author <a href="stefan.bodewig@epost.de">Stefan Bodewig</a>
* @version $Revision$


Loading…
Cancel
Save