on JDK 1.1 as well. Added org.apache.tools.ant to the list of packages that need to be loaded via the system class loader as the loaded class wouldn't be an instance of Task (loaded by default loader) otherwise. git-svn-id: https://svn.apache.org/repos/asf/ant/core/trunk@268038 13f79535-47bb-0310-9956-ffa450edef68master
@@ -115,7 +115,7 @@ public class AntClassLoader extends ClassLoader { | |||||
/** | /** | ||||
* Create a classloader for the given project using the classpath given. | * Create a classloader for the given project using the classpath given. | ||||
* | * | ||||
* @param project the project to ehich this classloader is to belong. | |||||
* @param project the project to which this classloader is to belong. | |||||
* @param classpath the classpath to use to load the classes. | * @param classpath the classpath to use to load the classes. | ||||
*/ | */ | ||||
public AntClassLoader(Project project, Path classpath, boolean systemFirst) { | public AntClassLoader(Project project, Path classpath, boolean systemFirst) { | ||||
@@ -129,7 +129,7 @@ public class AntClassLoader extends ClassLoader { | |||||
* | * | ||||
* All subpackages are also included. | * All subpackages are also included. | ||||
* | * | ||||
* @param packageRoot the root of akll packages to be included. | |||||
* @param packageRoot the root of all packages to be included. | |||||
*/ | */ | ||||
public void addSystemPackageRoot(String packageRoot) { | public void addSystemPackageRoot(String packageRoot) { | ||||
systemPackages.addElement(packageRoot + "."); | systemPackages.addElement(packageRoot + "."); | ||||
@@ -452,10 +452,10 @@ public class Project { | |||||
String msg = " +Task: " + taskType; | String msg = " +Task: " + taskType; | ||||
log (msg, MSG_DEBUG); | log (msg, MSG_DEBUG); | ||||
return task; | return task; | ||||
} catch (Exception e) { | |||||
} catch (Throwable t) { | |||||
String msg = "Could not create task of type: " | String msg = "Could not create task of type: " | ||||
+ taskType + " due to " + e; | |||||
throw new BuildException(msg); | |||||
+ taskType + " due to " + t; | |||||
throw new BuildException(msg, t); | |||||
} | } | ||||
} | } | ||||
@@ -95,7 +95,14 @@ public class Taskdef extends Task { | |||||
try { | try { | ||||
ClassLoader loader = null; | ClassLoader loader = null; | ||||
if (classpath != null) { | if (classpath != null) { | ||||
loader = new AntClassLoader(project, classpath, false); | |||||
AntClassLoader al = new AntClassLoader(project, classpath, | |||||
false); | |||||
al.addSystemPackageRoot("org.apache.tools.ant"); | |||||
if (project.getJavaVersion().startsWith("1.1")) { | |||||
// JDK > 1.1 adds these by default | |||||
al.addSystemPackageRoot("java"); | |||||
} | |||||
loader = al; | |||||
} else { | } else { | ||||
loader = this.getClass().getClassLoader(); | loader = this.getClass().getClassLoader(); | ||||
} | } | ||||
@@ -110,7 +117,11 @@ public class Taskdef extends Task { | |||||
} catch (ClassNotFoundException cnfe) { | } catch (ClassNotFoundException cnfe) { | ||||
String msg = "taskdef class " + value + | String msg = "taskdef class " + value + | ||||
" cannot be found"; | " cannot be found"; | ||||
throw new BuildException(msg, location); | |||||
throw new BuildException(msg, cnfe, location); | |||||
} catch (NoClassDefFoundError ncdfe) { | |||||
String msg = "taskdef class " + value + | |||||
" cannot be found"; | |||||
throw new BuildException(msg, ncdfe, location); | |||||
} | } | ||||
} | } | ||||