Browse Source

Add support for Package information to the ClassLoader

Rather than using reflection I have created a JDK 1.2+ specific
subclass of the AntClassLoader. This has necessitated replacing
direct construction of the classloader with a factory method in
Project. This factory method will attempt to create the new
class loader dynamically and then fall back to the current version if
the new loader is not available.

Existing users who construct the classloader directly will continue to
work as at Ant 1.5 - i.e. no package information is created. All Ant
code (except classloader) uses the new factory method

PR:	11196


git-svn-id: https://svn.apache.org/repos/asf/ant/core/trunk@273874 13f79535-47bb-0310-9956-ffa450edef68
master
Conor MacNeill 22 years ago
parent
commit
50ab376294
25 changed files with 876 additions and 583 deletions
  1. +3
    -0
      build.xml
  2. +116
    -56
      src/main/org/apache/tools/ant/AntClassLoader.java
  3. +29
    -0
      src/main/org/apache/tools/ant/Project.java
  4. +2
    -2
      src/main/org/apache/tools/ant/filters/util/ChainReaderHelper.java
  5. +186
    -0
      src/main/org/apache/tools/ant/loader/AntClassLoader2.java
  6. +14
    -13
      src/main/org/apache/tools/ant/taskdefs/Available.java
  7. +13
    -3
      src/main/org/apache/tools/ant/taskdefs/Definer.java
  8. +9
    -7
      src/main/org/apache/tools/ant/taskdefs/ExecuteJava.java
  9. +1
    -1
      src/main/org/apache/tools/ant/taskdefs/JDBCTask.java
  10. +1
    -1
      src/main/org/apache/tools/ant/taskdefs/Property.java
  11. +58
    -58
      src/main/org/apache/tools/ant/taskdefs/Rmic.java
  12. +1
    -1
      src/main/org/apache/tools/ant/taskdefs/XSLTProcess.java
  13. +4
    -3
      src/main/org/apache/tools/ant/taskdefs/optional/XMLValidateTask.java
  14. +54
    -55
      src/main/org/apache/tools/ant/taskdefs/optional/depend/Depend.java
  15. +2
    -1
      src/main/org/apache/tools/ant/taskdefs/optional/ejb/GenericDeploymentTool.java
  16. +287
    -287
      src/main/org/apache/tools/ant/taskdefs/optional/ejb/JonasDeploymentTool.java
  17. +1
    -1
      src/main/org/apache/tools/ant/taskdefs/optional/ejb/WeblogicDeploymentTool.java
  18. +7
    -7
      src/main/org/apache/tools/ant/taskdefs/optional/ejb/WebsphereDeploymentTool.java
  19. +4
    -4
      src/main/org/apache/tools/ant/taskdefs/optional/jsp/JspC.java
  20. +3
    -3
      src/main/org/apache/tools/ant/taskdefs/optional/jsp/compilers/JspCompilerAdapterFactory.java
  21. +23
    -21
      src/main/org/apache/tools/ant/taskdefs/optional/junit/JUnitTask.java
  22. +2
    -2
      src/main/org/apache/tools/ant/taskdefs/rmic/WLRmic.java
  23. +14
    -15
      src/main/org/apache/tools/ant/types/Mapper.java
  24. +40
    -40
      src/main/org/apache/tools/ant/types/XMLCatalog.java
  25. +2
    -2
      src/main/org/apache/tools/ant/types/selectors/ExtendSelector.java

+ 3
- 0
build.xml View File

@@ -144,6 +144,8 @@
<filename name="${optional.package}/sitraka/**"/>
<filename name="${optional.package}/ide/VAJ*"/>
<filename name="${optional.package}/starteam/*"/>
<!-- uses JDK 1.2 classloading facilities -->
<filename name="${ant.package}/loader/AntClassLoader2.java"/>
</or>
</selector>
<selector id="needs.jdk1.3+">
@@ -293,6 +295,7 @@
</patternset>
<patternset id="teststhatfail">
<exclude name="${optional.package}/BeanShellScriptTest.java"/>
<exclude name="${ant.package}/taskdefs/ImportTest.java"/>
</patternset>

<!--


+ 116
- 56
src/main/org/apache/tools/ant/AntClassLoader.java View File

@@ -1,7 +1,7 @@
/*
* The Apache Software License, Version 1.1
*
* Copyright (c) 2000-2002 The Apache Software Foundation. All rights
* Copyright (c) 2000-2003 The Apache Software Foundation. All rights
* reserved.
*
* Redistribution and use in source and binary forms, with or without
@@ -51,7 +51,6 @@
* information on the Apache Software Foundation, please see
* <http://www.apache.org/>.
*/

package org.apache.tools.ant;

import java.io.ByteArrayOutputStream;
@@ -97,7 +96,6 @@ public class AntClassLoader extends ClassLoader implements BuildListener {
* @author <a href="mailto:hermand@alumni.grinnell.edu">David A. Herman</a>
*/
private class ResourceEnumeration implements Enumeration {

/**
* The name of the resource being searched for.
*/
@@ -267,6 +265,13 @@ public class AntClassLoader extends ClassLoader implements BuildListener {
}


/**
* Create an Ant Class Loader
*/
public AntClassLoader() {
setParent(null);
}

/**
* Creates a classloader for the given project using the classpath given.
*
@@ -279,21 +284,9 @@ public class AntClassLoader extends ClassLoader implements BuildListener {
* elements are set up to start with.
*/
public AntClassLoader(Project project, Path classpath) {
parent = AntClassLoader.class.getClassLoader();
this.project = project;
project.addBuildListener(this);
if (classpath != null) {
Path actualClasspath = classpath.concatSystemClasspath("ignore");
String[] pathElements = actualClasspath.list();
for (int i = 0; i < pathElements.length; ++i) {
try {
addPathElement(pathElements[i]);
} catch (BuildException e) {
// ignore path elements which are invalid
// relative to the project
}
}
}
setParent(null);
setProject(project);
setClassPath(classpath);
}

/**
@@ -316,9 +309,9 @@ public class AntClassLoader extends ClassLoader implements BuildListener {
boolean parentFirst) {
this(project, classpath);
if (parent != null) {
this.parent = parent;
setParent(parent);
}
this.parentFirst = parentFirst;
setParentFirst(parentFirst);
addJavaLibraries();
}

@@ -354,15 +347,68 @@ public class AntClassLoader extends ClassLoader implements BuildListener {
* load the a class through this loader.
*/
public AntClassLoader(ClassLoader parent, boolean parentFirst) {
if (parent != null) {
this.parent = parent;
setParent(parent);
project = null;
this.parentFirst = parentFirst;
}

/**
* Set the project associated with this class loader
*
* @param project the project instance
*/
public void setProject(Project project) {
this.project = project;
if (project != null) {
project.addBuildListener(this);
}
}

/**
* Set the classpath to search for classes to load. This should not be
* changed once the classloader starts to server classes
*
* @param classpath the serahc classpath consisting of directories and
* jar/zip files.
*/
public void setClassPath(Path classpath) {
pathComponents.removeAllElements();
if (classpath != null) {
Path actualClasspath = classpath.concatSystemClasspath("ignore");
String[] pathElements = actualClasspath.list();
for (int i = 0; i < pathElements.length; ++i) {
try {
addPathElement(pathElements[i]);
} catch (BuildException e) {
// ignore path elements which are invalid
// relative to the project
}
}
}
}

/**
* Set the parent for this class loader. This is the class loader to which
* this class loader will delegate to load classes
*/
public void setParent(ClassLoader parent) {
if (parent == null) {
this.parent = AntClassLoader.class.getClassLoader();
} else {
parent = AntClassLoader.class.getClassLoader();
this.parent = parent;
}
project = null;
}

/**
* Control whether class ookup is delegated to the parent loader first
* or after this loader. Use with extreme caution. Setting this to
* false violates the class loader hierarchy and can lead to Linkage errors
*/
public void setParentFirst(boolean parentFirst) {
this.parentFirst = parentFirst;
}


/**
* Logs a message through the project object if one has been provided.
*
@@ -391,7 +437,7 @@ public class AntClassLoader extends ClassLoader implements BuildListener {
if (LoaderUtils.isContextLoaderAvailable()) {
savedContextLoader = LoaderUtils.getContextClassLoader();
ClassLoader loader = this;
if (project != null
if (project != null
&& "only".equals(project.getProperty("build.sysclasspath"))) {
loader = this.getClass().getClassLoader();
}
@@ -435,7 +481,7 @@ public class AntClassLoader extends ClassLoader implements BuildListener {
* @return the classpath used for this classloader, with elements
* separated by the path separator for the system.
*/
public String getClasspath(){
public String getClasspath() {
StringBuffer sb = new StringBuffer();
boolean firstPass = true;
Enumeration enum = pathComponents.elements();
@@ -513,7 +559,7 @@ public class AntClassLoader extends ClassLoader implements BuildListener {
* Should not be <code>null</code>.
*/
public void addSystemPackageRoot(String packageRoot) {
systemPackages.addElement(packageRoot
systemPackages.addElement(packageRoot
+ (packageRoot.endsWith(".") ? "" : "."));
}

@@ -834,7 +880,7 @@ public class AntClassLoader extends ClassLoader implements BuildListener {
}

/**
* Returns an inputstream to a given resource in the given file which may
* Returns the URL of a given resource in the given file which may
* either be a directory or a zip file.
*
* @param file The file (directory or jar) in which to search for
@@ -845,7 +891,7 @@ public class AntClassLoader extends ClassLoader implements BuildListener {
* @return a stream to the required resource or <code>null</code> if the
* resource cannot be found in the given file object.
*/
private URL getResourceURL(File file, String resourceName) {
protected URL getResourceURL(File file, String resourceName) {
try {
if (!file.exists()) {
return null;
@@ -962,32 +1008,16 @@ public class AntClassLoader extends ClassLoader implements BuildListener {
}

/**
* Reads a class definition from a stream.
* Define a class given its bytes
*
* @param stream The stream from which the class is to be read.
* Must not be <code>null</code>.
* @param classname The name of the class in the stream.
* Must not be <code>null</code>.
*
* @return the Class object read from the stream.
* @param container the container from which the class data has been read
* may be a directory or a jar/zip file.
*
* @exception IOException if there is a problem reading the class from the
* stream.
* @exception SecurityException if there is a security problem while
* reading the class from the stream.
* @param classData the bytecode data for the class
* @param classname the name of the class
*/
private Class getClassFromStream(InputStream stream, String classname)
throws IOException, SecurityException {
ByteArrayOutputStream baos = new ByteArrayOutputStream();
int bytesRead = -1;
byte[] buffer = new byte[BUFFER_SIZE];

while ((bytesRead = stream.read(buffer, 0, BUFFER_SIZE)) != -1) {
baos.write(buffer, 0, bytesRead);
}

byte[] classData = baos.toByteArray();

protected Class defineClassFromData(File container, byte[] classData,
String classname) throws IOException {
// Simply put:
// defineClass(classname, classData, 0, classData.length,
// Project.class.getProtectionDomain());
@@ -1018,6 +1048,36 @@ public class AntClassLoader extends ClassLoader implements BuildListener {
return defineClass(classname, classData, 0, classData.length);
}
}
/**
* Reads a class definition from a stream.
*
* @param stream The stream from which the class is to be read.
* Must not be <code>null</code>.
* @param classname The name of the class in the stream.
* Must not be <code>null</code>.
*
* @return the Class object read from the stream.
*
* @exception IOException if there is a problem reading the class from the
* stream.
* @exception SecurityException if there is a security problem while
* reading the class from the stream.
*/
private Class getClassFromStream(InputStream stream, String classname,
File container)
throws IOException, SecurityException {
ByteArrayOutputStream baos = new ByteArrayOutputStream();
int bytesRead = -1;
byte[] buffer = new byte[BUFFER_SIZE];

while ((bytesRead = stream.read(buffer, 0, BUFFER_SIZE)) != -1) {
baos.write(buffer, 0, bytesRead);
}

byte[] classData = baos.toByteArray();
return defineClassFromData(container, classData, classname);
}

/**
* Searches for and load a class on the classpath of this class loader.
@@ -1063,7 +1123,7 @@ public class AntClassLoader extends ClassLoader implements BuildListener {
if (stream != null) {
log("Loaded from " + pathComponent + " " + classFilename,
Project.MSG_DEBUG );
return getClassFromStream(stream, name);
return getClassFromStream(stream, name, pathComponent);
}
} catch (SecurityException se) {
throw se;
@@ -1182,12 +1242,12 @@ public class AntClassLoader extends ClassLoader implements BuildListener {
*/
public void messageLogged(BuildEvent event) {
}
/**
* add any libraries that come with different java versions
* here
*/
private void addJavaLibraries() {
public void addJavaLibraries() {
Vector packages=JavaEnvUtils.getJrePackages();
Enumeration e=packages.elements();
while(e.hasMoreElements()) {
@@ -1195,5 +1255,5 @@ public class AntClassLoader extends ClassLoader implements BuildListener {
addSystemPackageRoot(packageName);
}
}
}

+ 29
- 0
src/main/org/apache/tools/ant/Project.java View File

@@ -68,6 +68,7 @@ import org.apache.tools.ant.input.InputHandler;
import org.apache.tools.ant.types.FilterSet;
import org.apache.tools.ant.types.FilterSetCollection;
import org.apache.tools.ant.types.Description;
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.WeakishReference;
@@ -277,6 +278,34 @@ public class Project {
setSystemProperties();
}

private AntClassLoader createClassLoader() {
AntClassLoader loader = null;
if (!JavaEnvUtils.isJavaVersion(JavaEnvUtils.JAVA_1_1)) {
try {
// 1.2+ - create advanced helper dynamically
Class loaderClass
= Class.forName("org.apache.tools.ant.loader.AntClassLoader2");
loader = (AntClassLoader) loaderClass.newInstance();
} catch (Exception e) {
log("Unable to create Class Loader: "
+ e.getMessage(), Project.MSG_DEBUG);
}
}

if (loader == null) {
loader = new AntClassLoader();
}

loader.setProject(this);
return loader;
}

public AntClassLoader createClassLoader(Path path) {
AntClassLoader loader = createClassLoader();
loader.setClassPath(path);
return loader;
}

/**
* Sets the core classloader for the project. If a <code>null</code>
* classloader is specified, the parent classloader should be used.


+ 2
- 2
src/main/org/apache/tools/ant/filters/util/ChainReaderHelper.java View File

@@ -171,8 +171,8 @@ public final class ChainReaderHelper {
if (classpath == null) {
clazz = Class.forName(className);
} else {
AntClassLoader al = new AntClassLoader(project,
classpath);
AntClassLoader al
= project.createClassLoader(classpath);
clazz = al.loadClass(className);
AntClassLoader.initializeClass(clazz);
}


+ 186
- 0
src/main/org/apache/tools/ant/loader/AntClassLoader2.java View File

@@ -0,0 +1,186 @@
/*
* The Apache Software License, Version 1.1
*
* Copyright (c) 2003 The Apache Software Foundation. All rights
* reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
*
* 1. Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
*
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in
* the documentation and/or other materials provided with the
* distribution.
*
* 3. The end-user documentation included with the redistribution, if
* any, must include the following acknowlegement:
* "This product includes software developed by the
* Apache Software Foundation (http://www.apache.org/)."
* Alternately, this acknowlegement may appear in the software itself,
* if and wherever such third-party acknowlegements normally appear.
*
* 4. The names "The Jakarta Project", "Ant", and "Apache Software
* Foundation" must not be used to endorse or promote products derived
* from this software without prior written permission. For written
* permission, please contact apache@apache.org.
*
* 5. Products derived from this software may not be called "Apache"
* nor may "Apache" appear in their names without prior written
* permission of the Apache Group.
*
* THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED
* WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
* OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
* DISCLAIMED. IN NO EVENT SHALL THE APACHE SOFTWARE FOUNDATION OR
* ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
* USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
* OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
* OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
* SUCH DAMAGE.
* ====================================================================
*
* This software consists of voluntary contributions made by many
* individuals on behalf of the Apache Software Foundation. For more
* information on the Apache Software Foundation, please see
* <http://www.apache.org/>.
*/
package org.apache.tools.ant.loader;

import java.io.File;
import java.io.IOException;
import org.apache.tools.ant.AntClassLoader;
import org.apache.tools.ant.Project;
import java.util.jar.Manifest;
import java.util.jar.JarFile;
import java.util.jar.Attributes;
import java.util.jar.Attributes.Name;
import java.net.URL;
import java.net.MalformedURLException;

public class AntClassLoader2 extends AntClassLoader {
protected Class defineClassFromData(File container, byte[] classData,
String className) throws IOException {

definePackage(container, className);
return defineClass(className, classData, 0, classData.length,
Project.class.getProtectionDomain());
}
protected void definePackage(File container, String className)
throws IOException {
int classIndex = className.lastIndexOf('.');
if (classIndex == -1) {
return;
}
String packageName = className.substring(0, classIndex);
if (getPackage(packageName) != null) {
// already defined
return;
}
// define the package now
Manifest manifest = null;
if (!container.isDirectory()) {
JarFile jarFile = null;
try {
jarFile = new JarFile(container);
manifest = jarFile.getManifest();
} finally {
if (jarFile != null) {
jarFile.close();
}
}
}
if (manifest == null) {
definePackage(packageName, null, null, null, null, null, null, null);
} else {
definePackage(container, packageName, manifest);
}
}
protected void definePackage(File container, String packageName, Manifest manifest) {
String sectionName = packageName.replace('.', '/') + "/";

String specificationTitle = null;
String specificationVendor = null;
String specificationVersion = null;
String implementationTitle = null;
String implementationVendor = null;
String implementationVersion = null;
String sealedString = null;
URL sealBase = null;
Attributes sectionAttributes = manifest.getAttributes(sectionName);
if (sectionAttributes != null) {
specificationTitle
= sectionAttributes.getValue(Name.SPECIFICATION_TITLE);
specificationVendor
= sectionAttributes.getValue(Name.SPECIFICATION_VENDOR);
specificationVersion
= sectionAttributes.getValue(Name.SPECIFICATION_VERSION);
implementationTitle
= sectionAttributes.getValue(Name.IMPLEMENTATION_TITLE);
implementationVendor
= sectionAttributes.getValue(Name.IMPLEMENTATION_VENDOR);
implementationVersion
= sectionAttributes.getValue(Name.IMPLEMENTATION_VERSION);
sealedString
= sectionAttributes.getValue(Name.SEALED);
}
Attributes mainAttributes = manifest.getMainAttributes();
if (mainAttributes != null) {
if (specificationTitle == null) {
specificationTitle
= mainAttributes.getValue(Name.SPECIFICATION_TITLE);
}
if (specificationVendor == null) {
specificationVendor
= mainAttributes.getValue(Name.SPECIFICATION_VENDOR);
}
if (specificationVersion == null) {
specificationVersion
= mainAttributes.getValue(Name.SPECIFICATION_VERSION);
}
if (implementationTitle == null) {
implementationTitle
= mainAttributes.getValue(Name.IMPLEMENTATION_TITLE);
}
if (implementationVendor == null) {
implementationVendor
= mainAttributes.getValue(Name.IMPLEMENTATION_VENDOR);
}
if (implementationVersion == null) {
implementationVersion
= mainAttributes.getValue(Name.IMPLEMENTATION_VERSION);
}
if (sealedString == null) {
sealedString
= mainAttributes.getValue(Name.SEALED);
}
}
if (sealedString != null && sealedString.equalsIgnoreCase("true")) {
try {
sealBase = new URL("file:" + container.getPath());
} catch (MalformedURLException e) {
// ignore
}
}
definePackage(packageName, specificationTitle, specificationVersion,
specificationVendor, implementationTitle,
implementationVersion, implementationVendor, sealBase);
}
}


+ 14
- 13
src/main/org/apache/tools/ant/taskdefs/Available.java View File

@@ -67,10 +67,10 @@ import org.apache.tools.ant.util.FileUtils;
import org.apache.tools.ant.util.StringUtils;

/**
* Will set the given property if the requested resource is available at
* Will set the given property if the requested resource is available at
* runtime. This task may also be used as a condition by the condition task.
*
* @author Stefano Mazzocchi
* @author Stefano Mazzocchi
* <a href="mailto:stefano@apache.org">stefano@apache.org</a>
* @author Magesh Umasankar
*
@@ -94,7 +94,7 @@ public class Available extends Task implements Condition {

/**
* Set the classpath to be used when searching for classes and resources.
*
*
* @param classpath an Ant Path object containing the search path.
*/
public void setClasspath(Path classpath) {
@@ -116,7 +116,7 @@ public class Available extends Task implements Condition {
/**
* Set the classpath by reference.
*
* @param r a Reference to a Path instance to be used as the classpath
* @param r a Reference to a Path instance to be used as the classpath
* value.
*/
public void setClasspathRef(Reference r) {
@@ -166,7 +166,7 @@ public class Available extends Task implements Condition {
}

/**
* Set a classname of a class which must be available to set the given
* Set a classname of a class which must be available to set the given
* property.
*
* @param classname the name of the class required.
@@ -214,7 +214,7 @@ public class Available extends Task implements Condition {
* Set what type of file is required - either directory or file.
*
* @param type an instance of the FileDir enumeratedAttribute indicating
* whether the file required is to be a directory or a plain
* whether the file required is to be a directory or a plain
* file.
*/
public void setType(FileDir type) {
@@ -238,7 +238,7 @@ public class Available extends Task implements Condition {
*/
public void execute() throws BuildException {
if (property == null) {
throw new BuildException("property attribute is required",
throw new BuildException("property attribute is required",
getLocation());
}

@@ -282,7 +282,7 @@ public class Available extends Task implements Condition {

if (classpath != null) {
classpath.setProject(getProject());
this.loader = new AntClassLoader(getProject(), classpath);
this.loader = getProject().createClassLoader(classpath);
}

String appendix = "";
@@ -293,14 +293,14 @@ public class Available extends Task implements Condition {
}

if ((classname != null) && !checkClass(classname)) {
log("Unable to load class " + classname + appendix,
log("Unable to load class " + classname + appendix,
Project.MSG_VERBOSE);
return false;
}

if ((file != null) && !checkFile()) {
if (type != null) {
log("Unable to find " + type + " " + file + appendix,
log("Unable to find " + type + " " + file + appendix,
Project.MSG_VERBOSE);
} else {
log("Unable to find " + file + appendix, Project.MSG_VERBOSE);
@@ -309,7 +309,7 @@ public class Available extends Task implements Condition {
}

if ((resource != null) && !checkResource(resource)) {
log("Unable to load resource " + resource + appendix,
log("Unable to load resource " + resource + appendix,
Project.MSG_VERBOSE);
return false;
}
@@ -464,8 +464,9 @@ public class Available extends Task implements Condition {
try {
Class requiredClass = null;
if (ignoreSystemclasses) {
loader = new AntClassLoader(null, getProject(), classpath,
false);
loader = getProject().createClassLoader(classpath);
loader.setParentFirst(false);
loader.addJavaLibraries();
if (loader != null) {
try {
requiredClass = loader.findClass(classname);


+ 13
- 3
src/main/org/apache/tools/ant/taskdefs/Definer.java View File

@@ -316,12 +316,22 @@ public abstract class Definer extends Task {
if (classpath != null) {
project.log( "Creating new loader for taskdef using " + classpath +
" reverse=" + reverseLoader, Project.MSG_DEBUG );
al = new AntClassLoader(getProject(), classpath, !reverseLoader);
AntClassLoader acl = getProject().createClassLoader(classpath);
if (reverseLoader) {
acl.setParentFirst(false);
acl.addJavaLibraries();
}
al = acl;
} else {
// XXX Probably it would be better to reuse getClass().getClassLoader()
// I don't think we need a new ( identical ) loader for each task
al = new AntClassLoader(getProject(), Path.systemClasspath,
!reverseLoader);
AntClassLoader acl
= getProject().createClassLoader(Path.systemClasspath);
if (reverseLoader) {
acl.setParentFirst(false);
acl.addJavaLibraries();
}
al = acl;
}
// need to load Task via system classloader or the new
// task we want to define will never be a Task but always


+ 9
- 7
src/main/org/apache/tools/ant/taskdefs/ExecuteJava.java View File

@@ -91,7 +91,7 @@ public class ExecuteJava implements Runnable, TimeoutObserver {

/**
* Set the classpath to be used when running the Java class
*
*
* @param p an Ant Path object containing the classpath.
*/
public void setClasspath(Path p) {
@@ -121,7 +121,7 @@ public class ExecuteJava implements Runnable, TimeoutObserver {
public void execute(Project project) throws BuildException{
final String classname = javaCommand.getExecutable();

AntClassLoader loader = null;
AntClassLoader loader = null;
try {
if (sysProperties != null) {
sysProperties.setSystem();
@@ -132,8 +132,10 @@ public class ExecuteJava implements Runnable, TimeoutObserver {
if (classpath == null) {
target = Class.forName(classname);
} else {
loader = new AntClassLoader(project.getCoreLoader(), project,
classpath, false);
loader = project.createClassLoader(classpath);
loader.setParent(project.getCoreLoader());
loader.setParentFirst(false);
loader.addJavaLibraries();
loader.setIsolated(true);
loader.setThreadContextLoader();
target = loader.forceLoadClass(classname);
@@ -141,7 +143,7 @@ public class ExecuteJava implements Runnable, TimeoutObserver {
}
main = target.getMethod("main", param);
if (main == null) {
throw new BuildException("Could not find main() method in "
throw new BuildException("Could not find main() method in "
+ classname);
}

@@ -149,7 +151,7 @@ public class ExecuteJava implements Runnable, TimeoutObserver {
run();
} else {
thread = new Thread(this, "ExecuteJava");
Task currentThreadTask
Task currentThreadTask
= project.getThreadTask(Thread.currentThread());
project.registerThreadTask(thread, currentThreadTask);
// if we run into a timout, the run-away thread shall not
@@ -167,7 +169,7 @@ public class ExecuteJava implements Runnable, TimeoutObserver {
} catch (InterruptedException e) {}
if (timedOut) {
project.log("Timeout: sub-process interrupted",
Project.MSG_WARN);
Project.MSG_WARN);
} else {
thread = null;
w.stop();


+ 1
- 1
src/main/org/apache/tools/ant/taskdefs/JDBCTask.java View File

@@ -382,7 +382,7 @@ public abstract class JDBCTask extends Task {
log(
"Loading " + driver + " using AntClassLoader with classpath " + classpath,
Project.MSG_VERBOSE);
loader = new AntClassLoader(getProject(), classpath);
loader = getProject().createClassLoader(classpath);
if (caching) {
loaderMap.put(driver, loader);
}


+ 1
- 1
src/main/org/apache/tools/ant/taskdefs/Property.java View File

@@ -413,7 +413,7 @@ public class Property extends Task {
ClassLoader cL = null;

if (classpath != null) {
cL = new AntClassLoader(getProject(), classpath);
cL = getProject().createClassLoader(classpath);
} else {
cL = this.getClass().getClassLoader();
}


+ 58
- 58
src/main/org/apache/tools/ant/taskdefs/Rmic.java View File

@@ -81,13 +81,13 @@ import org.apache.tools.ant.util.facade.FacadeTaskHelper;
* specify the classname in the form <code>Outer$$Inner</code> instead of
* <code>Outer.Inner</code>.</p>
* <p>It is possible to refine the set of files that are being rmiced. This can be
* done with the <i>includes</i>, <i>includesfile</i>, <i>excludes</i>,
* done with the <i>includes</i>, <i>includesfile</i>, <i>excludes</i>,
* <i>excludesfile</i> and <i>defaultexcludes</i>
* attributes. With the <i>includes</i> or <i>includesfile</i> attribute you specify the files you want to
* have included by using patterns. The <i>exclude</i> or <i>excludesfile</i> attribute is used to specify
* the files you want to have excluded. This is also done with patterns. And
* finally with the <i>defaultexcludes</i> attribute, you can specify whether you
* want to use default exclusions or not. See the section on
* want to use default exclusions or not. See the section on
* directory based tasks</a>, on how the
* inclusion/exclusion of files works, and how to write patterns.</p>
* <p>This task forms an implicit FileSet and
@@ -100,11 +100,11 @@ import org.apache.tools.ant.util.facade.FacadeTaskHelper;
* attribute. <a name="compilervalues">There are three choices</a>:</p>
* <ul>
* <li>sun (the standard compiler of the JDK)</li>
* <li>kaffe (the standard compiler of
* <li>kaffe (the standard compiler of
* {@link <a href="http://www.kaffe.org">Kaffe</a>})</li>
* <li>weblogic</li>
* </ul>
*
*
* <p> The <a href="http://dione.zcu.cz/~toman40/miniRMI/">miniRMI</a>
* project contains a compiler implementation for this task as well,
* please consult miniRMI's documentation to learn how to use it.</p>
@@ -112,7 +112,7 @@ import org.apache.tools.ant.util.facade.FacadeTaskHelper;
* @author duncan@x180.com
* @author ludovic.claude@websitewatchers.co.uk
* @author David Maclean <a href="mailto:david@cm.co.za">david@cm.co.za</a>
* @author <a href="mailto:stefan.bodewig@epost.de">Stefan Bodewig</a>
* @author <a href="mailto:stefan.bodewig@epost.de">Stefan Bodewig</a>
* @author Takashi Okamoto tokamoto@rd.nttdata.co.jp
*
* @since Ant 1.1
@@ -122,7 +122,7 @@ import org.apache.tools.ant.util.facade.FacadeTaskHelper;

public class Rmic extends MatchingTask {

private static final String FAIL_MSG
private static final String FAIL_MSG
= "Rmic failed; see the compiler error output for details.";

private File baseDir;
@@ -159,22 +159,22 @@ public class Rmic extends MatchingTask {
}
}

/**
* Sets the location to store the compiled files; required
/**
* Sets the location to store the compiled files; required
*/
public void setBase(File base) {
this.baseDir = base;
}

/**
* Gets the base directory to output generated class.
/**
* Gets the base directory to output generated class.
*/
public File getBase() {
return this.baseDir;
}

/**
/**
* Sets the the class to run <code>rmic</code> against;
* optional
*/
@@ -183,7 +183,7 @@ public class Rmic extends MatchingTask {
}

/**
* Gets the class name to compile.
* Gets the class name to compile.
*/
public String getClassname() {
return classname;
@@ -197,7 +197,7 @@ public class Rmic extends MatchingTask {
}

/**
* Gets the source dirs to find the source java files.
* Gets the source dirs to find the source java files.
*/
public File getSourceBase() {
return sourceBase;
@@ -236,7 +236,7 @@ public class Rmic extends MatchingTask {
}

/**
* Gets the debug flag.
* Gets the debug flag.
*/
public boolean getDebug() {
return debug;
@@ -264,7 +264,7 @@ public class Rmic extends MatchingTask {
}

/**
* Adds to the classpath a reference to
* Adds to the classpath a reference to
* a &lt;path&gt; defined elsewhere.
*/
public void setClasspathRef(Reference r) {
@@ -272,19 +272,19 @@ public class Rmic extends MatchingTask {
}

/**
* Gets the classpath.
* Gets the classpath.
*/
public Path getClasspath() {
return compileClasspath;
return compileClasspath;
}

/**
* Flag to enable verification so that the classes
* Flag to enable verification so that the classes
* found by the directory match are
* checked to see if they implement java.rmi.Remote.
* Optional; his defaults to false if not set.
* Optional; his defaults to false if not set.
*/
public void setVerify(boolean verify) {
this.verify = verify;
}
@@ -296,73 +296,73 @@ public class Rmic extends MatchingTask {

/**
* Indicates that IIOP compatible stubs should
* be generated; optional, defaults to false
* if not set.
* be generated; optional, defaults to false
* if not set.
*/
public void setIiop(boolean iiop) {
this.iiop = iiop;
}

/**
* Gets iiop flags.
/**
* Gets iiop flags.
*/
public boolean getIiop() {
return iiop;
}

/**
* Set additional arguments for iiop
* Set additional arguments for iiop
*/
public void setIiopopts(String iiopopts) {
this.iiopopts = iiopopts;
}

/**
* Gets additional arguments for iiop.
* Gets additional arguments for iiop.
*/
public String getIiopopts() {
return iiopopts;
}

/**
* Indicates that IDL output should be
* generated. This defaults to false
* if not set.
* Indicates that IDL output should be
* generated. This defaults to false
* if not set.
*/
public void setIdl(boolean idl) {
this.idl = idl;
}

/**
* Gets IDL flags.
* Gets IDL flags.
*/
public boolean getIdl() {
return idl;
}

/**
* pass additional arguments for idl compile
* pass additional arguments for idl compile
*/
public void setIdlopts(String idlopts) {
this.idlopts = idlopts;
}

/**
* Gets additional arguments for idl compile.
* Gets additional arguments for idl compile.
*/
public String getIdlopts() {
return idlopts;
}

/**
* Gets file list to compile.
* Gets file list to compile.
*/
public Vector getFileList() {
return compileList;
}

/**
* Sets whether or not to include ant's own classpath in this task's
* Sets whether or not to include ant's own classpath in this task's
* classpath.
* Optional; default is <code>true</code>.
*/
@@ -382,7 +382,7 @@ public class Rmic extends MatchingTask {
* task's classpath.
* Enables or disables including the default run-time
* libraries from the executing VM; optional,
* defaults to false
* defaults to false
*/
public void setIncludejavaruntime(boolean include) {
includeJavaRuntime = include;
@@ -487,12 +487,12 @@ public class Rmic extends MatchingTask {
}

RmicAdapter adapter = RmicAdapterFactory.getRmic(getCompiler(), this);
// now we need to populate the compiler adapter
adapter.setRmic(this);

Path classpath = adapter.getClasspath();
loader = new AntClassLoader(getProject(), classpath);
loader = getProject().createClassLoader(classpath);

try {
// scan base dirs to build up compile lists only if a
@@ -503,36 +503,36 @@ public class Rmic extends MatchingTask {
scanDir(baseDir, files, adapter.getMapper());
} else {
// otherwise perform a timestamp comparison - at least
scanDir(baseDir,
new String[] {classname.replace('.',
scanDir(baseDir,
new String[] {classname.replace('.',
File.separatorChar)
+ ".class"},
adapter.getMapper());
}
int fileCount = compileList.size();
if (fileCount > 0) {
log("RMI Compiling " + fileCount +
" class" + (fileCount > 1 ? "es" : "") + " to " + baseDir,
" class" + (fileCount > 1 ? "es" : "") + " to " + baseDir,
Project.MSG_INFO);
// finally, lets execute the compiler!!
if (!adapter.execute()) {
throw new BuildException(FAIL_MSG, getLocation());
}
}
/*
/*
* Move the generated source file to the base directory. If
* base directory and sourcebase are the same, the generated
* sources are already in place.
*/
if (null != sourceBase && !baseDir.equals(sourceBase)
if (null != sourceBase && !baseDir.equals(sourceBase)
&& fileCount > 0) {
if (idl) {
log("Cannot determine sourcefiles in idl mode, ",
log("Cannot determine sourcefiles in idl mode, ",
Project.MSG_WARN);
log("sourcebase attribute will be ignored.",
log("sourcebase attribute will be ignored.",
Project.MSG_WARN);
} else {
for (int j = 0; j < fileCount; j++) {
@@ -558,9 +558,9 @@ public class Rmic extends MatchingTask {
RmicAdapter adapter)
throws BuildException {

String classFileName =
String classFileName =
classname.replace('.', File.separatorChar) + ".class";
String[] generatedFiles =
String[] generatedFiles =
adapter.getMapper().mapFileName(classFileName);

for (int i = 0; i < generatedFiles.length; i++) {
@@ -584,7 +584,7 @@ public class Rmic extends MatchingTask {
File newFile = new File(sourceBaseFile, sourceFileName);
try {
if (filtering) {
fileUtils.copyFile(oldFile, newFile,
fileUtils.copyFile(oldFile, newFile,
new FilterSetCollection(getProject()
.getGlobalFilterSet()));
} else {
@@ -610,7 +610,7 @@ public class Rmic extends MatchingTask {
if (idl) {
log("will leave uptodate test to rmic implementation in idl mode.",
Project.MSG_VERBOSE);
} else if (iiop
} else if (iiop
&& iiopopts != null && iiopopts.indexOf("-always") > -1) {
log("no uptodate test as -always option has been specified",
Project.MSG_VERBOSE);
@@ -638,13 +638,13 @@ public class Rmic extends MatchingTask {
}
return isValidRmiRemote(testClass);
} catch (ClassNotFoundException e) {
log("Unable to verify class " + classname +
log("Unable to verify class " + classname +
". It could not be found.", Project.MSG_WARN);
} catch (NoClassDefFoundError e) {
log("Unable to verify class " + classname +
log("Unable to verify class " + classname +
". It is not defined.", Project.MSG_WARN);
} catch (Throwable t) {
log("Unable to verify class " + classname +
log("Unable to verify class " + classname +
". Loading caused Exception: " +
t.getMessage(), Project.MSG_WARN);
}
@@ -690,12 +690,12 @@ public class Rmic extends MatchingTask {
* filter command line attributes based on the current
* implementation.
*/
public class ImplementationSpecificArgument extends
public class ImplementationSpecificArgument extends
org.apache.tools.ant.util.facade.ImplementationSpecificArgument {

/**
* Only pass the specified argument if the
* chosen compiler implementation matches the
* Only pass the specified argument if the
* chosen compiler implementation matches the
* value of this attribute. Legal values are
* the same as those in the above list of
* valid compilers.)


+ 1
- 1
src/main/org/apache/tools/ant/taskdefs/XSLTProcess.java View File

@@ -418,7 +418,7 @@ public class XSLTProcess extends MatchingTask implements XSLTLogger {
if (classpath == null) {
return Class.forName(classname);
} else {
AntClassLoader al = new AntClassLoader(getProject(), classpath);
AntClassLoader al = getProject().createClassLoader(classpath);
Class c = al.loadClass(classname);
AntClassLoader.initializeClass(c);
return c;


+ 4
- 3
src/main/org/apache/tools/ant/taskdefs/optional/XMLValidateTask.java View File

@@ -321,7 +321,8 @@ public class XMLValidateTask extends Task {
try {
// load the parser class
if (classpath != null) {
AntClassLoader loader = new AntClassLoader(getProject(), classpath);
AntClassLoader loader
= getProject().createClassLoader(classpath);
readerClass = loader.loadClass(readerClassName);
AntClassLoader.initializeClass(readerClass);
} else {
@@ -351,7 +352,7 @@ public class XMLValidateTask extends Task {
log("Using SAX1 parser " + reader.getClass().getName(),
Project.MSG_VERBOSE);
} else {
throw new BuildException(INIT_FAILED_MSG
throw new BuildException(INIT_FAILED_MSG
+ reader.getClass().getName()
+ " implements nor SAX1 Parser nor SAX2 XMLReader.");
}
@@ -381,7 +382,7 @@ public class XMLValidateTask extends Task {
* @param warn whether to war if the parser does not support the feature

*/
private void setFeature(String feature, boolean value)
private void setFeature(String feature, boolean value)
throws BuildException {

try {


+ 54
- 55
src/main/org/apache/tools/ant/taskdefs/optional/depend/Depend.java View File

@@ -89,10 +89,10 @@ public class Depend extends MatchingTask {

/** The Java class name of this class */
private String className;
/** The source File containing this class */
private File sourceFile;
/** if user has been warned about this file not having a source file */
private boolean isUserWarned = false;
}
@@ -108,7 +108,7 @@ public class Depend extends MatchingTask {

/** The list of source paths derived from the srcPath field. */
private String[] srcPathList;
/**
* A map which gives for every class a list of the class which it
* affects.
@@ -263,16 +263,16 @@ public class Depend extends MatchingTask {
}
}

/**
* Get the classpath for dependency checking.
*
/**
* Get the classpath for dependency checking.
*
* This method removes the dest dirs if it is given from the dependency classpath
*/
private Path getCheckClassPath() {
if (dependClasspath == null) {
return null;
}
String[] destPathElements = destPath.list();
String[] classpathElements = dependClasspath.list();
String checkPath = "";
@@ -290,14 +290,14 @@ public class Depend extends MatchingTask {
}
}
}
if (checkPath.length() == 0) {
return null;
}
return new Path(getProject(), checkPath);
}
}
/**
* Determine the dependencies between classes. Class dependencies are
* determined by examining the class references in a class file to other
@@ -307,7 +307,7 @@ public class Depend extends MatchingTask {
* <ul>
* <li>affectedClassMap - the list of classes each class affects</li>
* <li>classFileInfoMap - information about each class</li>
* <li>classpathDependencies - the list of jars and classes from the
* <li>classpathDependencies - the list of jars and classes from the
* classpath that each class depends upon.</li>
* </ul>
*
@@ -344,9 +344,9 @@ public class Depend extends MatchingTask {
Vector dependencyList = null;

if (cache != null) {
// try to read the dependency info from the map if it is
// try to read the dependency info from the map if it is
// not out of date
if (cacheFileExists
if (cacheFileExists
&& cacheLastModified > info.absoluteFile.lastModified()) {
// depFile exists and is newer than the class file
// need to get dependency list from the map.
@@ -377,7 +377,7 @@ public class Depend extends MatchingTask {
while (depEnum.hasMoreElements()) {
String dependentClass = (String) depEnum.nextElement();

Hashtable affectedClasses
Hashtable affectedClasses
= (Hashtable) affectedClassMap.get(dependentClass);
if (affectedClasses == null) {
affectedClasses = new Hashtable();
@@ -393,8 +393,7 @@ public class Depend extends MatchingTask {
if (checkPath != null) {
// now determine which jars each class depends upon
classpathDependencies = new Hashtable();
AntClassLoader loader
= new AntClassLoader(getProject(), checkPath);
AntClassLoader loader = getProject().createClassLoader(checkPath);

Hashtable classpathFileCache = new Hashtable();
Object nullFileMarker = new Object();
@@ -406,12 +405,12 @@ public class Depend extends MatchingTask {
Enumeration e2 = dependencyList.elements();
while (e2.hasMoreElements()) {
String dependency = (String) e2.nextElement();
Object classpathFileObject
Object classpathFileObject
= classpathFileCache.get(dependency);
if (classpathFileObject == null) {
classpathFileObject = nullFileMarker;

if (!dependency.startsWith("java.")
if (!dependency.startsWith("java.")
&& !dependency.startsWith("javax.")) {
URL classURL = loader.getResource(dependency.replace('.', '/') + ".class");
if (classURL != null) {
@@ -459,7 +458,7 @@ public class Depend extends MatchingTask {
for (Enumeration e = outOfDateClasses.elements(); e.hasMoreElements();) {
String className = (String) e.nextElement();
count += deleteAffectedFiles(className);
ClassFileInfo classInfo
ClassFileInfo classInfo
= (ClassFileInfo) classFileInfoMap.get(className);
if (classInfo != null && classInfo.absoluteFile.exists()) {
classInfo.absoluteFile.delete();
@@ -485,26 +484,26 @@ public class Depend extends MatchingTask {
}
for (Enumeration e = affectedClasses.keys(); e.hasMoreElements();) {
String affectedClass = (String) e.nextElement();
ClassFileInfo affectedClassInfo
ClassFileInfo affectedClassInfo
= (ClassFileInfo) affectedClasses.get(affectedClass);
if (!affectedClassInfo.absoluteFile.exists()) {
continue;
}
if (affectedClassInfo.sourceFile == null) {
if (!affectedClassInfo.isUserWarned) {
log("The class " + affectedClass + " in file "
+ affectedClassInfo.absoluteFile.getPath()
+ " is out of date due to " + className
+ " but has not been deleted because its source file"
log("The class " + affectedClass + " in file "
+ affectedClassInfo.absoluteFile.getPath()
+ " is out of date due to " + className
+ " but has not been deleted because its source file"
+ " could not be determined", Project.MSG_WARN);
affectedClassInfo.isUserWarned = true;
}
continue;
}

log("Deleting file " + affectedClassInfo.absoluteFile.getPath()
log("Deleting file " + affectedClassInfo.absoluteFile.getPath()
+ " since " + className + " out of date", Project.MSG_VERBOSE);

affectedClassInfo.absoluteFile.delete();
@@ -521,15 +520,15 @@ public class Depend extends MatchingTask {
// need to delete the main class
String topLevelClassName
= affectedClass.substring(0, affectedClass.indexOf("$"));
log("Top level class = " + topLevelClassName,
log("Top level class = " + topLevelClassName,
Project.MSG_VERBOSE);
ClassFileInfo topLevelClassInfo
= (ClassFileInfo) classFileInfoMap.get(topLevelClassName);
if (topLevelClassInfo != null &&
topLevelClassInfo.absoluteFile.exists()) {
log("Deleting file "
+ topLevelClassInfo.absoluteFile.getPath()
+ " since one of its inner classes was removed",
log("Deleting file "
+ topLevelClassInfo.absoluteFile.getPath()
+ " since one of its inner classes was removed",
Project.MSG_VERBOSE);
topLevelClassInfo.absoluteFile.delete();
count++;
@@ -549,33 +548,33 @@ public class Depend extends MatchingTask {
log("Reverse Dependency Dump for " + affectedClassMap.size() +
" classes:", Project.MSG_DEBUG);

Enumeration classEnum = affectedClassMap.keys();
Enumeration classEnum = affectedClassMap.keys();
while (classEnum.hasMoreElements()) {
String className = (String) classEnum.nextElement();
log(" Class " + className + " affects:", Project.MSG_DEBUG);
Hashtable affectedClasses
Hashtable affectedClasses
= (Hashtable) affectedClassMap.get(className);
Enumeration affectedClassEnum = affectedClasses.keys();
Enumeration affectedClassEnum = affectedClasses.keys();
while (affectedClassEnum.hasMoreElements()) {
String affectedClass = (String) affectedClassEnum.nextElement();
ClassFileInfo info
ClassFileInfo info
= (ClassFileInfo) affectedClasses.get(affectedClass);
log(" " + affectedClass + " in "
log(" " + affectedClass + " in "
+ info.absoluteFile.getPath(), Project.MSG_DEBUG);
}
}

if (classpathDependencies != null) {
log("Classpath file dependencies (Forward):", Project.MSG_DEBUG);
Enumeration classpathEnum = classpathDependencies.keys();
Enumeration classpathEnum = classpathDependencies.keys();
while (classpathEnum.hasMoreElements()) {
String className = (String) classpathEnum.nextElement();
log(" Class " + className + " depends on:", Project.MSG_DEBUG);
Hashtable dependencies
Hashtable dependencies
= (Hashtable) classpathDependencies.get(className);

Enumeration classpathFileEnum = dependencies.elements();
Enumeration classpathFileEnum = dependencies.elements();
while (classpathFileEnum.hasMoreElements()) {
File classpathFile = (File) classpathFileEnum.nextElement();
log(" " + classpathFile.getPath(), Project.MSG_DEBUG);
@@ -594,7 +593,7 @@ public class Depend extends MatchingTask {
scanDir(srcDir, files);
}
}
// now check classpath file dependencies
if (classpathDependencies == null) {
return;
@@ -606,17 +605,17 @@ public class Depend extends MatchingTask {
if (outOfDateClasses.containsKey(className)) {
continue;
}
ClassFileInfo info
ClassFileInfo info
= (ClassFileInfo) classFileInfoMap.get(className);

// if we have no info about the class - it may have been deleted already and we
// are using cached info.
if (info != null) {
Hashtable dependencies
Hashtable dependencies
= (Hashtable) classpathDependencies.get(className);
for (Enumeration e2 = dependencies.elements(); e2.hasMoreElements();) {
File classpathFile = (File) e2.nextElement();
if (classpathFile.lastModified()
if (classpathFile.lastModified()
> info.absoluteFile.lastModified()) {
log("Class " + className +
" is out of date with respect to " + classpathFile, Project.MSG_DEBUG);
@@ -627,7 +626,7 @@ public class Depend extends MatchingTask {
}
}
}
/**
* Does the work.
*
@@ -652,7 +651,7 @@ public class Depend extends MatchingTask {
}

if (cache != null && cache.exists() && !cache.isDirectory()) {
throw new BuildException("The cache, if specified, must "
throw new BuildException("The cache, if specified, must "
+ "point to a directory");
}

@@ -668,7 +667,7 @@ public class Depend extends MatchingTask {
int count = deleteAllAffectedFiles();

long duration = (System.currentTimeMillis() - start) / 1000;
log("Deleted " + count + " out of date files in "
log("Deleted " + count + " out of date files in "
+ duration + " seconds");
} catch (Exception e) {
throw new BuildException(e);
@@ -690,17 +689,17 @@ public class Depend extends MatchingTask {
File srcFile = new File(srcDir, files[i]);
if (files[i].endsWith(".java")) {
String filePath = srcFile.getPath();
String className
String className
= filePath.substring(srcDir.getPath().length() + 1,
filePath.length() - ".java".length());
className = ClassFileUtils.convertSlashName(className);
ClassFileInfo info
ClassFileInfo info
= (ClassFileInfo) classFileInfoMap.get(className);
if (info == null) {
// there was no class file. add this class to the list
outOfDateClasses.put(className, className);
} else {
if (srcFile.lastModified()
if (srcFile.lastModified()
> info.absoluteFile.lastModified()) {
outOfDateClasses.put(className, className);
}
@@ -744,7 +743,7 @@ public class Depend extends MatchingTask {
if (innerIndex != -1) {
sourceFilename = classname.substring(0, innerIndex) + ".java";
}
// search the various source path entries
for (int i = 0; i < srcPathList.length; ++i) {
File sourceFile = new File(srcPathList[i], sourceFilename);
@@ -754,7 +753,7 @@ public class Depend extends MatchingTask {
}
return null;
}
/**
* Add the list of class files from the given directory to the class
* file vector, including any subdirectories.
@@ -785,9 +784,9 @@ public class Depend extends MatchingTask {
info.absoluteFile = file;
String relativeName = file.getPath().substring(rootLength + 1,
file.getPath().length() - 6);
info.className
info.className
= ClassFileUtils.convertSlashName(relativeName);
info.sourceFile = findSourceFile(relativeName);
info.sourceFile = findSourceFile(relativeName);
classFileList.addElement(info);
}
}


+ 2
- 1
src/main/org/apache/tools/ant/taskdefs/optional/ejb/GenericDeploymentTool.java View File

@@ -924,7 +924,8 @@ public class GenericDeploymentTool implements EJBDeploymentTool {
if (combinedClasspath == null) {
classpathLoader = getClass().getClassLoader();
} else {
classpathLoader = new AntClassLoader(getTask().getProject(), combinedClasspath);
classpathLoader
= getTask().getProject().createClassLoader(combinedClasspath);
}

return classpathLoader;


+ 287
- 287
src/main/org/apache/tools/ant/taskdefs/optional/ejb/JonasDeploymentTool.java View File

@@ -112,7 +112,7 @@ public class JonasDeploymentTool extends GenericDeploymentTool {

/** GenIC class name (JOnAS 2.5) */
protected static final String GENIC_CLASS =
"org.objectweb.jonas_ejb.genic.GenIC";
"org.objectweb.jonas_ejb.genic.GenIC";

/** Old GenIC class name (JOnAS 2.4.x). */
protected static final String OLD_GENIC_CLASS_1 =
@@ -185,7 +185,7 @@ public class JonasDeploymentTool extends GenericDeploymentTool {

/**
* <code>true</code> if the GenIC call must be verbose. The default
* is <code>false</code>.
* is <code>false</code>.
*/
private boolean verbose = false;

@@ -202,12 +202,12 @@ public class JonasDeploymentTool extends GenericDeploymentTool {
/**
* <code>true</code> if the generic JAR file used as input to GenIC must be
* retained. The default is <code>false</code>.
*/
*/
private boolean keepgeneric = false;

/** Stores the suffix for the JOnAS JAR file. The default is '.jar'. */
private String suffix = ".jar";
/**
* ORB to use (RMI, JEREMIE or DAVID). If omitted, it defaults to the one
* present in classpath. If specified, the corresponding JOnAS JAR is
@@ -215,7 +215,7 @@ public class JonasDeploymentTool extends GenericDeploymentTool {
*/
private String orb;

/** <code>true</code> if GenIC must not be run on the EJB JAR. The default is <code>false</code>. */
/** <code>true</code> if GenIC must not be run on the EJB JAR. The default is <code>false</code>. */
private boolean nogenic = false;

/* -------------------- */
@@ -309,7 +309,7 @@ public class JonasDeploymentTool extends GenericDeploymentTool {

/**
* Set the JOnAS root directory.
*
*
* @param aFile the JOnAS root directory.
*/
public void setJonasroot(File aFile) {
@@ -357,46 +357,46 @@ public class JonasDeploymentTool extends GenericDeploymentTool {
/* ------------- */

public void processDescriptor(String aDescriptorName, SAXParser saxParser) {
descriptorName = aDescriptorName;
log("JOnAS Deployment Tool processing: " + descriptorName,
Project.MSG_VERBOSE);

super.processDescriptor(descriptorName, saxParser);

if ( outputdir != null ) {
// the method deleteOnExit() do not work because the directory is not empty
log("Deleting temp output directory '" + outputdir + "'.", Project.MSG_VERBOSE);
deleteAllFiles(outputdir);
}
if ( outputdir != null ) {
// the method deleteOnExit() do not work because the directory is not empty
log("Deleting temp output directory '" + outputdir + "'.", Project.MSG_VERBOSE);
deleteAllFiles(outputdir);
}
}

protected void writeJar(String baseName, File jarfile, Hashtable ejbFiles, String publicId)
throws BuildException {
// create the generic jar first
File genericJarFile = super.getVendorOutputJarFile(baseName);
super.writeJar(baseName, genericJarFile, ejbFiles, publicId);
// GenIC call on generic jar
addGenICGeneratedFiles(genericJarFile, ejbFiles);
// create the real jar
super.writeJar(baseName, getVendorOutputJarFile(baseName), ejbFiles, publicId);
if ( !keepgeneric ) {
log("Deleting generic JAR " + genericJarFile.toString(), Project.MSG_VERBOSE);
genericJarFile.delete();
}
protected void writeJar(String baseName, File jarfile, Hashtable ejbFiles, String publicId)
throws BuildException {
// create the generic jar first
File genericJarFile = super.getVendorOutputJarFile(baseName);
super.writeJar(baseName, genericJarFile, ejbFiles, publicId);
// GenIC call on generic jar
addGenICGeneratedFiles(genericJarFile, ejbFiles);
// create the real jar
super.writeJar(baseName, getVendorOutputJarFile(baseName), ejbFiles, publicId);
if ( !keepgeneric ) {
log("Deleting generic JAR " + genericJarFile.toString(), Project.MSG_VERBOSE);
genericJarFile.delete();
}
}

protected void addVendorFiles(Hashtable ejbFiles, String ddPrefix) {

// JOnAS-specific descriptor deployment
jonasDescriptorName = getJonasDescriptorName();
// JOnAS-specific descriptor deployment
jonasDescriptorName = getJonasDescriptorName();
File jonasDD = new File(getConfig().descriptorDir, jonasDescriptorName);
if ( jonasDD.exists() ) {
ejbFiles.put(META_DIR + JONAS_DD, jonasDD);
} else {
@@ -422,14 +422,14 @@ public class JonasDeploymentTool extends GenericDeploymentTool {
// descriptorName = <path><basename><basenameterminator><remainder>
// examples = /org/objectweb/fooAppli/foo/Foo-ejb-jar.xml
// examples = /org/objectweb/fooAppli/foo/Foo.xml (JOnAS convention)
String jonasDescriptorName; // JOnAS-specific DD
boolean jonasConvention = false; // true if the JOnAS convention is used for the DD
String path; // Directory path of the EJB descriptor
String fileName; // EJB descriptor file name
String baseName; // Filename appearing before name terminator
String remainder; // Filename appearing after the name terminator
int startOfFileName = descriptorName.lastIndexOf(File.separatorChar);
if ( startOfFileName != -1 ) {
// extract path info
@@ -440,18 +440,18 @@ public class JonasDeploymentTool extends GenericDeploymentTool {
path = "";
fileName = descriptorName;
}
if ( fileName.startsWith(EJB_DD) )
return path + JONAS_DD;

int endOfBaseName = descriptorName.indexOf(getConfig().baseNameTerminator, startOfFileName);
/*
* Check for the odd case where the terminator and/or filename
* extension aren't found. These will ensure "jonas-" appears at the
* end of the name and before the '.' (if present).
*/
if ( endOfBaseName < 0 ) {
if ( endOfBaseName < 0 ) {
// baseNameTerminator not found: the descriptor use the
// JOnAS naming convention, ie [Foo.xml,jonas-Foo.xml] and
// not [Foo<baseNameTerminator>-ejb-jar.xml,
@@ -461,22 +461,22 @@ public class JonasDeploymentTool extends GenericDeploymentTool {
// no . found
endOfBaseName = descriptorName.length() - 1;
}
jonasConvention = true;
}

baseName = descriptorName.substring(startOfFileName + 1, endOfBaseName + 1);
remainder = descriptorName.substring(endOfBaseName + 1);
if ( jonasConvention ) {
jonasDescriptorName = path + "jonas-" + baseName + ".xml";
} else {
jonasDescriptorName = path + baseName + "jonas-" + remainder;
}
log("Standard EJB descriptor name: " + descriptorName, Project.MSG_VERBOSE);
log("JOnAS-specific descriptor name: " + jonasDescriptorName, Project.MSG_VERBOSE);
return jonasDescriptorName;
}

@@ -489,11 +489,11 @@ public class JonasDeploymentTool extends GenericDeploymentTool {
// try to find JOnAS specific convention name
if ( descriptorFileName.indexOf(getConfig().baseNameTerminator) == -1 ) {

// baseNameTerminator not found: the descriptor use the
// JOnAS naming convention, ie [Foo.xml,jonas-Foo.xml] and
// not [Foo<baseNameTerminator>-ejb-jar.xml,
// Foo<baseNameTerminator>-jonas-ejb-jar.xml].
// baseNameTerminator not found: the descriptor use the
// JOnAS naming convention, ie [Foo.xml,jonas-Foo.xml] and
// not [Foo<baseNameTerminator>-ejb-jar.xml,
// Foo<baseNameTerminator>-jonas-ejb-jar.xml].
String aCanonicalDescriptor = descriptorFileName.replace('\\', '/');
int lastSeparatorIndex = aCanonicalDescriptor.lastIndexOf('/');
int endOfBaseName;
@@ -514,22 +514,22 @@ public class JonasDeploymentTool extends GenericDeploymentTool {
// else get standard baseName
baseName = super.getJarBaseName(descriptorFileName);
}
log("JAR base name: " + baseName, Project.MSG_VERBOSE);
log("JAR base name: " + baseName, Project.MSG_VERBOSE);

return baseName;
}

protected void registerKnownDTDs(DescriptorHandler handler) {
handler.registerDTD(EJB_JAR_1_1_PUBLIC_ID,
jonasroot + File.separator + "xml" + File.separator + EJB_JAR_1_1_DTD);
handler.registerDTD(EJB_JAR_2_0_PUBLIC_ID,
jonasroot + File.separator + "xml" + File.separator + EJB_JAR_2_0_DTD);
handler.registerDTD(JONAS_EJB_JAR_2_4_PUBLIC_ID,
jonasroot + File.separator + "xml" + File.separator + JONAS_EJB_JAR_2_4_DTD);
handler.registerDTD(JONAS_EJB_JAR_2_5_PUBLIC_ID,
jonasroot + File.separator + "xml" + File.separator + JONAS_EJB_JAR_2_5_DTD);
handler.registerDTD(EJB_JAR_1_1_PUBLIC_ID,
jonasroot + File.separator + "xml" + File.separator + EJB_JAR_1_1_DTD);
handler.registerDTD(EJB_JAR_2_0_PUBLIC_ID,
jonasroot + File.separator + "xml" + File.separator + EJB_JAR_2_0_DTD);
handler.registerDTD(JONAS_EJB_JAR_2_4_PUBLIC_ID,
jonasroot + File.separator + "xml" + File.separator + JONAS_EJB_JAR_2_4_DTD);
handler.registerDTD(JONAS_EJB_JAR_2_5_PUBLIC_ID,
jonasroot + File.separator + "xml" + File.separator + JONAS_EJB_JAR_2_5_DTD);
}

/**
@@ -539,154 +539,154 @@ public class JonasDeploymentTool extends GenericDeploymentTool {
* @param ejbFiles the hashtable.
*/
private void addGenICGeneratedFiles(File genericJarFile, Hashtable ejbFiles) {
Java genicTask = null; // GenIC task
String genicClass = null; // GenIC class (3 GenIC classes for various versions of JOnAS are supported)

Java genicTask = null; // GenIC task
String genicClass = null; // GenIC class (3 GenIC classes for various versions of JOnAS are supported)
if ( nogenic ) {
return;
}

genicTask = (Java) getTask().getProject().createTask("java");
genicTask.setTaskName("genic");
genicTask.setFork(true);
// jonasroot
genicTask.createJvmarg().setValue("-Dinstall.root=" + jonasroot);
// java policy file
String jonasConfigDir = jonasroot + File.separator + "config";
File javaPolicyFile = new File(jonasConfigDir, "java.policy");
if ( javaPolicyFile.exists() ) {
genicTask.createJvmarg().setValue("-Djava.security.policy="
+ javaPolicyFile.toString());
}
// outputdir
try {
outputdir = createTempDir();
} catch (IOException aIOException) {
String msg = "Cannot create temp dir: " + aIOException.getMessage();
throw new BuildException(msg, aIOException);
}
log("Using temporary output directory: " + outputdir, Project.MSG_VERBOSE);
genicTask.createArg().setValue("-d");
genicTask.createArg().setFile(outputdir);
// work around a bug of GenIC 2.5
String key;
File f;
Enumeration keys = ejbFiles.keys();
while ( keys.hasMoreElements() ) {
key = (String)keys.nextElement();
f = new File(outputdir + File.separator + key);
f.getParentFile().mkdirs();
}
log("Worked around a bug of GenIC 2.5.", Project.MSG_VERBOSE);

// classpath
Path classpath = getCombinedClasspath();
if ( classpath == null ) {
classpath = new Path(getTask().getProject());
}
classpath.append(new Path(classpath.getProject(), jonasConfigDir));
classpath.append(new Path(classpath.getProject(), outputdir.toString()));
// try to create the classpath for the correct ORB
if ( orb != null ) {
String orbJar = jonasroot + File.separator + "lib" + File.separator + orb + "_jonas.jar";
classpath.append(new Path(classpath.getProject(), orbJar));
}
log("Using classpath: " + classpath.toString(), Project.MSG_VERBOSE);
genicTask.setClasspath(classpath);
// class name (search in the classpath provided for the ejbjar element)
genicClass = getGenicClassName(classpath);
if ( genicClass == null ) {
log("Cannot find GenIC class in classpath.", Project.MSG_ERR);
throw new BuildException("GenIC class not found, please check the classpath.");
} else {
log("Using '" + genicClass + "' GenIC class." , Project.MSG_VERBOSE);
genicTask.setClassname(genicClass);
}
// keepgenerated
if ( keepgenerated ) {
genicTask.createArg().setValue("-keepgenerated");
}
// nocompil
if ( nocompil ) {
genicTask.createArg().setValue("-nocompil");
}
// novalidation
if ( novalidation ) {
genicTask.createArg().setValue("-novalidation");
}
// javac
if ( javac != null ) {
genicTask.createArg().setValue("-javac");
genicTask.createArg().setLine(javac);
}
// javacopts
if ( javacopts != null && !javacopts.equals("") ) {
genicTask.createArg().setValue("-javacopts");
genicTask.createArg().setLine(javacopts);
}

// rmicopts
if ( rmicopts != null && !rmicopts.equals("") ) {
genicTask.createArg().setValue("-rmicopts");
genicTask.createArg().setLine(rmicopts);
}
// secpropag
if ( secpropag ) {
genicTask.createArg().setValue("-secpropag");
}
// verbose
if ( verbose ) {
genicTask.createArg().setValue("-verbose");
return;
}
genicTask = (Java) getTask().getProject().createTask("java");
genicTask.setTaskName("genic");
genicTask.setFork(true);
// jonasroot
genicTask.createJvmarg().setValue("-Dinstall.root=" + jonasroot);
// java policy file
String jonasConfigDir = jonasroot + File.separator + "config";
File javaPolicyFile = new File(jonasConfigDir, "java.policy");
if ( javaPolicyFile.exists() ) {
genicTask.createJvmarg().setValue("-Djava.security.policy="
+ javaPolicyFile.toString());
}
// outputdir
try {
outputdir = createTempDir();
} catch (IOException aIOException) {
String msg = "Cannot create temp dir: " + aIOException.getMessage();
throw new BuildException(msg, aIOException);
}
log("Using temporary output directory: " + outputdir, Project.MSG_VERBOSE);
genicTask.createArg().setValue("-d");
genicTask.createArg().setFile(outputdir);
// work around a bug of GenIC 2.5
String key;
File f;
Enumeration keys = ejbFiles.keys();
while ( keys.hasMoreElements() ) {
key = (String)keys.nextElement();
f = new File(outputdir + File.separator + key);
f.getParentFile().mkdirs();
}
log("Worked around a bug of GenIC 2.5.", Project.MSG_VERBOSE);
// classpath
Path classpath = getCombinedClasspath();
if ( classpath == null ) {
classpath = new Path(getTask().getProject());
}
classpath.append(new Path(classpath.getProject(), jonasConfigDir));
classpath.append(new Path(classpath.getProject(), outputdir.toString()));
// try to create the classpath for the correct ORB
if ( orb != null ) {
String orbJar = jonasroot + File.separator + "lib" + File.separator + orb + "_jonas.jar";
classpath.append(new Path(classpath.getProject(), orbJar));
}
log("Using classpath: " + classpath.toString(), Project.MSG_VERBOSE);
genicTask.setClasspath(classpath);
// class name (search in the classpath provided for the ejbjar element)
genicClass = getGenicClassName(classpath);
if ( genicClass == null ) {
log("Cannot find GenIC class in classpath.", Project.MSG_ERR);
throw new BuildException("GenIC class not found, please check the classpath.");
} else {
log("Using '" + genicClass + "' GenIC class." , Project.MSG_VERBOSE);
genicTask.setClassname(genicClass);
}
// keepgenerated
if ( keepgenerated ) {
genicTask.createArg().setValue("-keepgenerated");
}
// nocompil
if ( nocompil ) {
genicTask.createArg().setValue("-nocompil");
}
// novalidation
if ( novalidation ) {
genicTask.createArg().setValue("-novalidation");
}
// javac
if ( javac != null ) {
genicTask.createArg().setValue("-javac");
genicTask.createArg().setLine(javac);
}
// javacopts
if ( javacopts != null && !javacopts.equals("") ) {
genicTask.createArg().setValue("-javacopts");
genicTask.createArg().setLine(javacopts);
}
// rmicopts
if ( rmicopts != null && !rmicopts.equals("") ) {
genicTask.createArg().setValue("-rmicopts");
genicTask.createArg().setLine(rmicopts);
}
// secpropag
if ( secpropag ) {
genicTask.createArg().setValue("-secpropag");
}
// verbose
if ( verbose ) {
genicTask.createArg().setValue("-verbose");
}
// additionalargs
if ( additionalargs != null ) {
genicTask.createArg().setValue(additionalargs);
}
// the generated classes must not be added in the generic JAR!
// is that buggy on old JOnAS (2.4) ??
genicTask.createArg().setValue("-noaddinjar");
// input file to process by GenIC
genicTask.createArg().setValue(genericJarFile.getPath());
// calling GenIC task
log("Calling " + genicClass + " for " + getConfig().descriptorDir + File.separator + descriptorName
+ ".", Project.MSG_VERBOSE);
if ( genicTask.executeJava() != 0 ) {
// the method deleteOnExit() do not work because the directory is not empty
log("Deleting temp output directory '" + outputdir + "'.", Project.MSG_VERBOSE);
deleteAllFiles(outputdir);
if ( !keepgeneric ) {
log("Deleting generic JAR " + genericJarFile.toString(), Project.MSG_VERBOSE);
genericJarFile.delete();
}
// additionalargs
if ( additionalargs != null ) {
genicTask.createArg().setValue(additionalargs);
}
// the generated classes must not be added in the generic JAR!
// is that buggy on old JOnAS (2.4) ??
genicTask.createArg().setValue("-noaddinjar");
// input file to process by GenIC
genicTask.createArg().setValue(genericJarFile.getPath());

// calling GenIC task
log("Calling " + genicClass + " for " + getConfig().descriptorDir + File.separator + descriptorName
+ ".", Project.MSG_VERBOSE);

if ( genicTask.executeJava() != 0 ) {

// the method deleteOnExit() do not work because the directory is not empty
log("Deleting temp output directory '" + outputdir + "'.", Project.MSG_VERBOSE);
deleteAllFiles(outputdir);

if ( !keepgeneric ) {
log("Deleting generic JAR " + genericJarFile.toString(), Project.MSG_VERBOSE);
genericJarFile.delete();
}

throw new BuildException("GenIC reported an error.");
}
// add the generated files to the ejbFiles
addAllFiles(outputdir, "", ejbFiles);
throw new BuildException("GenIC reported an error.");
}
// add the generated files to the ejbFiles
addAllFiles(outputdir, "", ejbFiles);
}

/**
@@ -698,77 +698,77 @@ public class JonasDeploymentTool extends GenericDeploymentTool {
*/
String getGenicClassName(Path classpath) {

log("Looking for GenIC class in classpath: " + classpath.toString(), Project.MSG_VERBOSE);
AntClassLoader cl = new AntClassLoader(classpath.getProject(), classpath);
try {
cl.loadClass(JonasDeploymentTool.GENIC_CLASS);
log("Found GenIC class '" + JonasDeploymentTool.GENIC_CLASS + "' in classpath.", Project.MSG_VERBOSE);
return JonasDeploymentTool.GENIC_CLASS;
} catch (ClassNotFoundException cnf1) {
log("GenIC class '" + JonasDeploymentTool.GENIC_CLASS + "' not found in classpath.",
Project.MSG_VERBOSE);
}
try {
cl.loadClass(JonasDeploymentTool.OLD_GENIC_CLASS_1);
log("Found GenIC class '" + JonasDeploymentTool.OLD_GENIC_CLASS_1 +
"' in classpath.", Project.MSG_VERBOSE);
return JonasDeploymentTool.OLD_GENIC_CLASS_1;
} catch (ClassNotFoundException cnf2) {
log("GenIC class '" + JonasDeploymentTool.OLD_GENIC_CLASS_1 +
"' not found in classpath.",
Project.MSG_VERBOSE);
}
try {
cl.loadClass(JonasDeploymentTool.OLD_GENIC_CLASS_2);
log("Found GenIC class '" + JonasDeploymentTool.OLD_GENIC_CLASS_2 +
"' in classpath.", Project.MSG_VERBOSE);
return JonasDeploymentTool.OLD_GENIC_CLASS_2;
} catch (ClassNotFoundException cnf3) {
log("GenIC class '" + JonasDeploymentTool.OLD_GENIC_CLASS_2 +
"' not found in classpath.",
Project.MSG_VERBOSE);
}
return null;
log("Looking for GenIC class in classpath: " + classpath.toString(), Project.MSG_VERBOSE);
AntClassLoader cl = classpath.getProject().createClassLoader(classpath);
try {
cl.loadClass(JonasDeploymentTool.GENIC_CLASS);
log("Found GenIC class '" + JonasDeploymentTool.GENIC_CLASS + "' in classpath.", Project.MSG_VERBOSE);
return JonasDeploymentTool.GENIC_CLASS;
} catch (ClassNotFoundException cnf1) {
log("GenIC class '" + JonasDeploymentTool.GENIC_CLASS + "' not found in classpath.",
Project.MSG_VERBOSE);
}
try {
cl.loadClass(JonasDeploymentTool.OLD_GENIC_CLASS_1);
log("Found GenIC class '" + JonasDeploymentTool.OLD_GENIC_CLASS_1 +
"' in classpath.", Project.MSG_VERBOSE);
return JonasDeploymentTool.OLD_GENIC_CLASS_1;
} catch (ClassNotFoundException cnf2) {
log("GenIC class '" + JonasDeploymentTool.OLD_GENIC_CLASS_1 +
"' not found in classpath.",
Project.MSG_VERBOSE);
}
try {
cl.loadClass(JonasDeploymentTool.OLD_GENIC_CLASS_2);
log("Found GenIC class '" + JonasDeploymentTool.OLD_GENIC_CLASS_2 +
"' in classpath.", Project.MSG_VERBOSE);
return JonasDeploymentTool.OLD_GENIC_CLASS_2;
} catch (ClassNotFoundException cnf3) {
log("GenIC class '" + JonasDeploymentTool.OLD_GENIC_CLASS_2 +
"' not found in classpath.",
Project.MSG_VERBOSE);
}
return null;
}

protected void checkConfiguration(String descriptorFileName,
SAXParser saxParser) throws BuildException {
// jonasroot
if ( jonasroot == null ) {
throw new BuildException("The jonasroot attribut is not set.");
} else if ( !jonasroot.isDirectory() ) {
throw new BuildException("The jonasroot attribut '" + jonasroot +
"' is not a valid directory.");
}
// orb
if ( orb != null && !orb.equals(RMI_ORB) && !orb.equals(JEREMIE_ORB) && !orb.equals(DAVID_ORB) ) {
throw new BuildException("The orb attribut '" + orb + "' is not valid (must be either " +
RMI_ORB + ", " + JEREMIE_ORB + " or " + DAVID_ORB + ").");
}
// additionalargs
if ( additionalargs != null && additionalargs.equals("") ) {
throw new BuildException("Empty additionalargs attribut.");
}
// javac
if ( javac != null && javac.equals("") ) {
throw new BuildException("Empty javac attribut.");
}
SAXParser saxParser) throws BuildException {
// jonasroot
if ( jonasroot == null ) {
throw new BuildException("The jonasroot attribut is not set.");
} else if ( !jonasroot.isDirectory() ) {
throw new BuildException("The jonasroot attribut '" + jonasroot +
"' is not a valid directory.");
}
// orb
if ( orb != null && !orb.equals(RMI_ORB) && !orb.equals(JEREMIE_ORB) && !orb.equals(DAVID_ORB) ) {
throw new BuildException("The orb attribut '" + orb + "' is not valid (must be either " +
RMI_ORB + ", " + JEREMIE_ORB + " or " + DAVID_ORB + ").");
}
// additionalargs
if ( additionalargs != null && additionalargs.equals("") ) {
throw new BuildException("Empty additionalargs attribut.");
}
// javac
if ( javac != null && javac.equals("") ) {
throw new BuildException("Empty javac attribut.");
}
}

/* ----------------------------------------------------------------------------------- */
/* utilitary methods */
/* ----------------------------------------------------------------------------------- */
/* ----------------------------------------------------------------------------------- */

/**
* Create a temporary directory for GenIC output.
@@ -776,13 +776,13 @@ public class JonasDeploymentTool extends GenericDeploymentTool {
* @return the temp directory.
* @throws BuildException if a temp directory cannot be created.
*/
private File createTempDir() throws IOException {
File tmpDir = File.createTempFile("genic", null, null);
tmpDir.delete();
if ( !tmpDir.mkdir() ) {
throw new IOException("Cannot create the temporary directory '" + tmpDir + "'.");
}
return tmpDir;
private File createTempDir() throws IOException {
File tmpDir = File.createTempFile("genic", null, null);
tmpDir.delete();
if ( !tmpDir.mkdir() ) {
throw new IOException("Cannot create the temporary directory '" + tmpDir + "'.");
}
return tmpDir;
}

/**
@@ -813,20 +813,20 @@ public class JonasDeploymentTool extends GenericDeploymentTool {
private void addAllFiles(File file, String rootDir, Hashtable hashtable) {

if ( !file.exists() ) {
throw new IllegalArgumentException();
}
String newRootDir;
throw new IllegalArgumentException();
}
String newRootDir;
if ( file.isDirectory() ) {
File files[] = file.listFiles();
for (int i = 0; i < files.length; i++) {
if ( rootDir.length() > 0 ) {
newRootDir = rootDir + File.separator + files[i].getName();
} else {
newRootDir = files[i].getName();
}
addAllFiles(files[i], newRootDir, hashtable);
}
File files[] = file.listFiles();
for (int i = 0; i < files.length; i++) {
if ( rootDir.length() > 0 ) {
newRootDir = rootDir + File.separator + files[i].getName();
} else {
newRootDir = files[i].getName();
}
addAllFiles(files[i], newRootDir, hashtable);
}
} else {
hashtable.put(rootDir, file);
}


+ 1
- 1
src/main/org/apache/tools/ant/taskdefs/optional/ejb/WeblogicDeploymentTool.java View File

@@ -891,7 +891,7 @@ public class WeblogicDeploymentTool extends GenericDeploymentTool {
lookupPath.append(classpath);
}

return new AntClassLoader(getTask().getProject(), lookupPath);
return getTask().getProject().createClassLoader(lookupPath);
}
}


+ 7
- 7
src/main/org/apache/tools/ant/taskdefs/optional/ejb/WebsphereDeploymentTool.java View File

@@ -236,7 +236,7 @@ public class WebsphereDeploymentTool extends GenericDeploymentTool {


/**
* Flag, default false, to only generate the deployment
* Flag, default false, to only generate the deployment
* code, do not run RMIC or Javac
*
* @param codegen option
@@ -247,7 +247,7 @@ public class WebsphereDeploymentTool extends GenericDeploymentTool {


/**
* Flag, default true, to only output error messages.
* Flag, default true, to only output error messages.
*
* @param quiet option
*/
@@ -279,7 +279,7 @@ public class WebsphereDeploymentTool extends GenericDeploymentTool {
/**
* Flag to disable informational messages; optional, default false.
*
* @param noinfom
* @param noinfom
*/
public void setNoinform(boolean noinfom) {
this.noinform = noinform;
@@ -300,8 +300,8 @@ public class WebsphereDeploymentTool extends GenericDeploymentTool {
*
* @param options
*/
public void setRmicoptions(String options) {
this.rmicOptions = options;
public void setRmicoptions(String options) {
this.rmicOptions = options;
}

/**
@@ -315,7 +315,7 @@ public class WebsphereDeploymentTool extends GenericDeploymentTool {


/**
* The compiler (switch <code>-compiler</code>) to use
* The compiler (switch <code>-compiler</code>) to use
*/
public void setCompiler(String compiler) {
this.compiler = compiler;
@@ -922,7 +922,7 @@ public class WebsphereDeploymentTool extends GenericDeploymentTool {
lookupPath.append(classpath);
}

return new AntClassLoader(getTask().getProject(), lookupPath);
return getTask().getProject().createClassLoader(lookupPath);
}
}


+ 4
- 4
src/main/org/apache/tools/ant/taskdefs/optional/jsp/JspC.java View File

@@ -415,19 +415,19 @@ public class JspC extends MatchingTask {
//bind to a compiler
JspCompilerAdapter compiler =
JspCompilerAdapterFactory.getCompiler(compilerName, this,
new AntClassLoader(getProject(), compilerClasspath));
getProject().createClassLoader(compilerClasspath));

//if we are a webapp, hand off to the compiler, which had better handle it
if(webApp!=null) {
doCompilation(compiler);
return;
}
// make sure that we've got a srcdir
// make sure that we've got a srcdir
if (src == null) {
throw new BuildException("srcdir attribute must be set!",
location);
}
}
String [] list = src.list();
if (list.length == 0) {
throw new BuildException("srcdir attribute must be set!",


+ 3
- 3
src/main/org/apache/tools/ant/taskdefs/optional/jsp/compilers/JspCompilerAdapterFactory.java View File

@@ -88,8 +88,8 @@ public class JspCompilerAdapterFactory {
*/
public static JspCompilerAdapter getCompiler(String compilerType, Task task)
throws BuildException {
return getCompiler(compilerType, task,
new AntClassLoader(task.getProject(), null));
return getCompiler(compilerType, task,
task.getProject().createClassLoader(null));
}

/**
@@ -105,7 +105,7 @@ public class JspCompilerAdapterFactory {
* @param compilerType either the name of the desired compiler, or the
* full classname of the compiler's adapter.
* @param task a task to log through.
* @param loader AntClassLoader with which the compiler should be loaded
* @param loader AntClassLoader with which the compiler should be loaded
* @throws BuildException if the compiler type could not be resolved into
* a compiler adapter.
*/


+ 23
- 21
src/main/org/apache/tools/ant/taskdefs/optional/junit/JUnitTask.java View File

@@ -590,7 +590,7 @@ public class JUnitTask extends Task {
* exceeds a certain amount of time. Can be <tt>null</tt>, in this case
* the test could probably hang forever.
*/
private int executeAsForked(JUnitTest test, ExecuteWatchdog watchdog)
private int executeAsForked(JUnitTest test, ExecuteWatchdog watchdog)
throws BuildException {

CommandlineJava cmd = (CommandlineJava) commandline.clone();
@@ -599,7 +599,7 @@ public class JUnitTask extends Task {
cmd.createArgument().setValue(test.getName());
cmd.createArgument().setValue("filtertrace=" + test.getFiltertrace());
cmd.createArgument().setValue("haltOnError=" + test.getHaltonerror());
cmd.createArgument().setValue("haltOnFailure="
cmd.createArgument().setValue("haltOnFailure="
+ test.getHaltonfailure());
if (includeAntRuntime) {
log("Implicitly adding " + antRuntimeClasses + " to CLASSPATH",
@@ -614,7 +614,7 @@ public class JUnitTask extends Task {
.setValue("formatter=org.apache.tools.ant.taskdefs.optional.junit.SummaryJUnitResultFormatter");
}

cmd.createArgument().setValue("showoutput="
cmd.createArgument().setValue("showoutput="
+ String.valueOf(showOutput));

StringBuffer formatterArg = new StringBuffer(128);
@@ -634,10 +634,10 @@ public class JUnitTask extends Task {

// Create a temporary file to pass the Ant properties to the
// forked test
File propsFile =
File propsFile =
FileUtils.newFileUtils().createTempFile("junit", ".properties",
getProject().getBaseDir());
cmd.createArgument().setValue("propsfile="
cmd.createArgument().setValue("propsfile="
+ propsFile.getAbsolutePath());
Hashtable p = getProject().getProperties();
Properties props = new Properties();
@@ -655,8 +655,8 @@ public class JUnitTask extends Task {
+ "file.", e, getLocation());
}

Execute execute = new Execute(new LogStreamHandler(this,
Project.MSG_INFO,
Execute execute = new Execute(new LogStreamHandler(this,
Project.MSG_INFO,
Project.MSG_WARN),
watchdog);
execute.setCommandline(cmd.getCommandline());
@@ -741,7 +741,7 @@ public class JUnitTask extends Task {
JUnitTest test = (JUnitTest) arg.clone();
test.setProperties(getProject().getProperties());
if (dir != null) {
log("dir attribute ignored if running in the same VM",
log("dir attribute ignored if running in the same VM",
Project.MSG_WARN);
}

@@ -750,27 +750,29 @@ public class JUnitTask extends Task {
+ "the same VM.", Project.MSG_WARN);
}

CommandlineJava.SysProperties sysProperties =
CommandlineJava.SysProperties sysProperties =
commandline.getSystemProperties();
if (sysProperties != null) {
sysProperties.setSystem();
}
AntClassLoader cl = null;
try {
log("Using System properties " + System.getProperties(),
log("Using System properties " + System.getProperties(),
Project.MSG_VERBOSE);
Path userClasspath = commandline.getClasspath();
Path classpath = userClasspath == null
? null
Path classpath = userClasspath == null
? null
: (Path) userClasspath.clone();
if (classpath != null) {
if (includeAntRuntime) {
log("Implicitly adding " + antRuntimeClasses
log("Implicitly adding " + antRuntimeClasses
+ " to CLASSPATH", Project.MSG_VERBOSE);
classpath.append(antRuntimeClasses);
}

cl = new AntClassLoader(null, getProject(), classpath, false);
cl = getProject().createClassLoader(classpath);
cl.setParentFirst(false);
cl.addJavaLibraries();
log("Using CLASSPATH " + cl.getClasspath(),
Project.MSG_VERBOSE);

@@ -780,13 +782,13 @@ public class JUnitTask extends Task {
cl.addSystemPackageRoot("org.apache.tools.ant");
cl.setThreadContextLoader();
}
runner = new JUnitTestRunner(test, test.getHaltonerror(),
test.getFiltertrace(),
runner = new JUnitTestRunner(test, test.getHaltonerror(),
test.getFiltertrace(),
test.getHaltonfailure(), cl);
if (summary) {
log("Running " + test.getName(), Project.MSG_INFO);

SummaryJUnitResultFormatter f =
SummaryJUnitResultFormatter f =
new SummaryJUnitResultFormatter();
f.setWithOutAndErr("withoutanderr"
.equalsIgnoreCase(summaryValue));
@@ -876,7 +878,7 @@ public class JUnitTask extends Task {
return feArray;
}

/**
/**
* If the formatter sends output to a file, return that file.
* null otherwise.
*
@@ -929,7 +931,7 @@ public class JUnitTask extends Task {
}

/**
* Take care that some output is produced in report files if the
* Take care that some output is produced in report files if the
* watchdog kills the test.
*
* @since Ant 1.5.2
@@ -948,13 +950,13 @@ public class JUnitTask extends Task {
test.setCounts(0,0,1);
Test t = new Test() {
public int countTestCases() { return 0; }
public void run(TestResult r) {
public void run(TestResult r) {
throw new AssertionFailedError("Timeout occurred");
}
};
formatter.startTest(t);
formatter
.addError(t,
.addError(t,
new AssertionFailedError("Timeout occurred"));

formatter.endTestSuite(test);


+ 2
- 2
src/main/org/apache/tools/ant/taskdefs/rmic/WLRmic.java View File

@@ -79,8 +79,8 @@ public class WLRmic extends DefaultRmicAdapter {
if (getRmic().getClasspath() == null) {
c = Class.forName("weblogic.rmic");
} else {
loader = new AntClassLoader(getRmic().getProject(),
getRmic().getClasspath());
loader
= getRmic().getProject().createClassLoader(getRmic().getClasspath());
c = loader.loadClass("weblogic.rmic");
AntClassLoader.initializeClass(c);
}


+ 14
- 15
src/main/org/apache/tools/ant/types/Mapper.java View File

@@ -64,7 +64,7 @@ import org.apache.tools.ant.util.FileNameMapper;
/**
* Element to define a FileNameMapper.
*
* @author <a href="mailto:stefan.bodewig@epost.de">Stefan Bodewig</a>
* @author <a href="mailto:stefan.bodewig@epost.de">Stefan Bodewig</a>
*/
public class Mapper extends DataType implements Cloneable {

@@ -180,7 +180,7 @@ public class Mapper extends DataType implements Cloneable {
if (isReference()) {
return getRef().getImplementation();
}
if (type == null && classname == null) {
throw new BuildException("one of the attributes type or classname is required");
}
@@ -198,12 +198,11 @@ public class Mapper extends DataType implements Cloneable {
if (classpath == null) {
c = Class.forName(classname);
} else {
AntClassLoader al = new AntClassLoader(getProject(),
classpath);
AntClassLoader al = getProject().createClassLoader(classpath);
c = al.loadClass(classname);
AntClassLoader.initializeClass(c);
}
FileNameMapper m = (FileNameMapper) c.newInstance();
m.setFrom(from);
m.setTo(to);
@@ -218,10 +217,10 @@ public class Mapper extends DataType implements Cloneable {
}
}
}
/**
* Performs the check for circular references and returns the
* referenced Mapper.
* referenced Mapper.
*/
protected Mapper getRef() {
if (!isChecked()) {
@@ -229,7 +228,7 @@ public class Mapper extends DataType implements Cloneable {
stk.push(this);
dieOnCircularReference(stk, getProject());
}
Object o = getRefid().getReferencedObject(getProject());
if (!(o instanceof Mapper)) {
String msg = getRefid().getRefId() + " doesn\'t denote a mapper";
@@ -247,22 +246,22 @@ public class Mapper extends DataType implements Cloneable {

public MapperType() {
implementations = new Properties();
implementations.put("identity",
implementations.put("identity",
"org.apache.tools.ant.util.IdentityMapper");
implementations.put("flatten",
implementations.put("flatten",
"org.apache.tools.ant.util.FlatFileNameMapper");
implementations.put("glob",
implementations.put("glob",
"org.apache.tools.ant.util.GlobPatternMapper");
implementations.put("merge",
implementations.put("merge",
"org.apache.tools.ant.util.MergingMapper");
implementations.put("regexp",
implementations.put("regexp",
"org.apache.tools.ant.util.RegexpPatternMapper");
implementations.put("package",
implementations.put("package",
"org.apache.tools.ant.util.PackageNameMapper");
}

public String[] getValues() {
return new String[] {"identity", "flatten", "glob",
return new String[] {"identity", "flatten", "glob",
"merge", "regexp", "package"};
}



+ 40
- 40
src/main/org/apache/tools/ant/types/XMLCatalog.java View File

@@ -160,7 +160,7 @@ import org.xml.sax.XMLReader;
* @author Jeff Turner
* @version $Id$
*/
public class XMLCatalog extends DataType
public class XMLCatalog extends DataType
implements Cloneable, EntityResolver, URIResolver {

/** helper for some File.toURL connversions */
@@ -180,7 +180,7 @@ public class XMLCatalog extends DataType
* Path listing external catalog files to search when resolving entities
*/
private Path catalogPath;
/**
* The name of the bridge to the Apache xml-commons resolver
* class, used to determine whether resolver.jar is present in the
@@ -436,7 +436,7 @@ public class XMLCatalog extends DataType
log("resolveEntity: '" + publicId + "': '" + systemId + "'",
Project.MSG_DEBUG);

InputSource inputSource =
InputSource inputSource =
getCatalogResolver().resolveEntity(publicId, systemId);

if (inputSource == null) {
@@ -463,7 +463,7 @@ public class XMLCatalog extends DataType
}

SAXSource source = null;
String uri = removeFragment(href);

log("resolve: '" + uri + "' with base: '" + base + "'", Project.MSG_DEBUG);
@@ -507,7 +507,7 @@ public class XMLCatalog extends DataType

/**
* Factory method for creating the appropriate CatalogResolver
* strategy implementation.
* strategy implementation.
* <p> Until we query the classpath, we don't know whether the Apache
* resolver (Norm Walsh's library from xml-commons) is available or not.
* This method determines whether the library is available and creates the
@@ -521,7 +521,7 @@ public class XMLCatalog extends DataType

AntClassLoader loader = null;

loader = new AntClassLoader(getProject(), Path.systemClasspath);
loader = getProject().createClassLoader(Path.systemClasspath);

try {
Class clazz = loader.forceLoadSystemClass(APACHE_RESOLVER);
@@ -531,10 +531,10 @@ public class XMLCatalog extends DataType
// available, so use it.
//
catalogResolver = new ApacheResolver(clazz, obj);
}
}
catch (Throwable ex) {
//
// The xml-commons resolver library is not
// The xml-commons resolver library is not
// available, so we can't use it.
//
catalogResolver = new InternalResolver();
@@ -593,7 +593,7 @@ public class XMLCatalog extends DataType
*
* @param publicId the publicId of the Resource for which local information
* is required.
* @return a ResourceLocation instance with information on the local location
* @return a ResourceLocation instance with information on the local location
* of the Resource or null if no such information is available.
*/
private ResourceLocation findMatchingEntry(String publicId) {
@@ -656,17 +656,17 @@ public class XMLCatalog extends DataType
throw new BuildException("Project basedir cannot be converted to a URL");
}
}
InputSource source = null;
URL url = null;
try {
url = new URL(baseURL, uri);
}
catch (MalformedURLException ex) {
// ignore
}
if (url != null) {
String fileName = url.getFile();
if (fileName != null) {
@@ -707,7 +707,7 @@ public class XMLCatalog extends DataType
} else {
cp = (new Path(getProject())).concatSystemClasspath("last");
}
loader = new AntClassLoader(getProject(), cp);
loader = getProject().createClassLoader(cp);

//
// for classpath lookup we ignore the base directory
@@ -734,7 +734,7 @@ public class XMLCatalog extends DataType
* if the resource does not identify a valid URL or is not readable.
*/
private InputSource urlLookup(ResourceLocation matchingEntry) {
String uri = matchingEntry.getLocation();
URL baseURL = null;

@@ -799,7 +799,7 @@ public class XMLCatalog extends DataType
* library (Norm Walsh's library from xml-commons) is not
* available. In this case, external catalog files will be
* ignored.
*
*
*/
private class InternalResolver implements CatalogResolver {

@@ -815,8 +815,8 @@ public class XMLCatalog extends DataType

if (matchingEntry != null) {

log("Matching catalog entry found for publicId: '" +
matchingEntry.getPublicId() + "' location: '" +
log("Matching catalog entry found for publicId: '" +
matchingEntry.getPublicId() + "' location: '" +
matchingEntry.getLocation() + "'",
Project.MSG_DEBUG);

@@ -843,8 +843,8 @@ public class XMLCatalog extends DataType

if (matchingEntry != null) {

log("Matching catalog entry found for uri: '" +
matchingEntry.getPublicId() + "' location: '" +
log("Matching catalog entry found for uri: '" +
matchingEntry.getPublicId() + "' location: '" +
matchingEntry.getLocation() + "'",
Project.MSG_DEBUG);

@@ -857,7 +857,7 @@ public class XMLCatalog extends DataType
//
// This is the standard behavior as per my reading of
// the JAXP and XML Catalog specs. CKS 11/7/2002
//
//
ResourceLocation entryCopy = matchingEntry;
if (base != null) {
try {
@@ -895,7 +895,7 @@ public class XMLCatalog extends DataType
* library (Norm Walsh's library from xml-commons) is available in
* the classpath. The ApacheResolver is a essentially a superset
* of the InternalResolver.
*
*
*/
private class ApacheResolver implements CatalogResolver {

@@ -909,7 +909,7 @@ public class XMLCatalog extends DataType

private boolean externalCatalogsProcessed = false;

public ApacheResolver(Class resolverImplClass,
public ApacheResolver(Class resolverImplClass,
Object resolverImpl) {

this.resolverImpl = resolverImpl;
@@ -924,22 +924,22 @@ public class XMLCatalog extends DataType
try {
setXMLCatalog =
resolverImplClass.getMethod("setXMLCatalog",
new Class[]
new Class[]
{ XMLCatalog.class });

parseCatalog =
resolverImplClass.getMethod("parseCatalog",
new Class[]
new Class[]
{ String.class });

resolveEntity =
resolverImplClass.getMethod("resolveEntity",
new Class[]
new Class[]
{ String.class, String.class });

resolve =
resolverImplClass.getMethod("resolve",
new Class[]
new Class[]
{ String.class, String.class });
}
catch (NoSuchMethodException ex) {
@@ -960,8 +960,8 @@ public class XMLCatalog extends DataType

if (matchingEntry != null) {

log("Matching catalog entry found for publicId: '" +
matchingEntry.getPublicId() + "' location: '" +
log("Matching catalog entry found for publicId: '" +
matchingEntry.getPublicId() + "' location: '" +
matchingEntry.getLocation() + "'",
Project.MSG_DEBUG);

@@ -973,7 +973,7 @@ public class XMLCatalog extends DataType

if (result == null) {
try {
result =
result =
(InputSource)resolveEntity.invoke(resolverImpl,
new Object[]
{ publicId, systemId });
@@ -993,7 +993,7 @@ public class XMLCatalog extends DataType
// this possibility.
//
try {
result =
result =
(InputSource)resolveEntity.invoke(resolverImpl,
new Object[]
{ publicId, systemId });
@@ -1018,8 +1018,8 @@ public class XMLCatalog extends DataType

if (matchingEntry != null) {

log("Matching catalog entry found for uri: '" +
matchingEntry.getPublicId() + "' location: '" +
log("Matching catalog entry found for uri: '" +
matchingEntry.getPublicId() + "' location: '" +
matchingEntry.getLocation() + "'",
Project.MSG_DEBUG);

@@ -1034,7 +1034,7 @@ public class XMLCatalog extends DataType
//
// This is the standard behavior as per my reading of
// the JAXP and XML Catalog specs. CKS 11/7/2002
//
//
ResourceLocation entryCopy = matchingEntry;
if (base != null) {
try {
@@ -1059,7 +1059,7 @@ public class XMLCatalog extends DataType
result = new SAXSource(source);
} else {
try {
result =
result =
(SAXSource)resolve.invoke(resolverImpl,
new Object[]
{ href, base });
@@ -1079,7 +1079,7 @@ public class XMLCatalog extends DataType
// this possibility.
//
try {
result =
result =
(SAXSource)resolve.invoke(resolverImpl,
new Object[]
{ href, base });
@@ -1103,8 +1103,8 @@ public class XMLCatalog extends DataType
if (externalCatalogsProcessed == false) {

try {
setXMLCatalog.invoke(resolverImpl,
new Object[]
setXMLCatalog.invoke(resolverImpl,
new Object[]
{ XMLCatalog.this });
}
catch (Exception ex) {
@@ -1118,11 +1118,11 @@ public class XMLCatalog extends DataType
String[] catPathList = getCatalogPath().list();

for (int i=0; i< catPathList.length; i++) {
File catFile = new File(catPathList[i]);
File catFile = new File(catPathList[i]);
log("Parsing "+catFile, Project.MSG_DEBUG);
try {
parseCatalog.invoke(resolverImpl,
new Object[]
parseCatalog.invoke(resolverImpl,
new Object[]
{ catFile.getPath() });
}
catch (Exception ex) {


+ 2
- 2
src/main/org/apache/tools/ant/types/selectors/ExtendSelector.java View File

@@ -100,8 +100,8 @@ public class ExtendSelector extends BaseSelector {
if (classpath == null) {
c = Class.forName(classname);
} else {
AntClassLoader al = new AntClassLoader(getProject(),
classpath);
AntClassLoader al
= getProject().createClassLoader(classpath);
c = al.loadClass(classname);
AntClassLoader.initializeClass(c);
}


Loading…
Cancel
Save