You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@ant.apache.org by co...@apache.org on 2003/01/24 15:18:23 UTC

cvs commit: jakarta-ant/src/main/org/apache/tools/ant/types/selectors ExtendSelector.java

conor       2003/01/24 06:18:23

  Modified:    .        build.xml
               src/main/org/apache/tools/ant AntClassLoader.java
                        Project.java
               src/main/org/apache/tools/ant/filters/util
                        ChainReaderHelper.java
               src/main/org/apache/tools/ant/taskdefs Available.java
                        Definer.java ExecuteJava.java JDBCTask.java
                        Property.java Rmic.java XSLTProcess.java
               src/main/org/apache/tools/ant/taskdefs/optional
                        XMLValidateTask.java
               src/main/org/apache/tools/ant/taskdefs/optional/depend
                        Depend.java
               src/main/org/apache/tools/ant/taskdefs/optional/ejb
                        GenericDeploymentTool.java JonasDeploymentTool.java
                        WeblogicDeploymentTool.java
                        WebsphereDeploymentTool.java
               src/main/org/apache/tools/ant/taskdefs/optional/jsp
                        JspC.java
               src/main/org/apache/tools/ant/taskdefs/optional/jsp/compilers
                        JspCompilerAdapterFactory.java
               src/main/org/apache/tools/ant/taskdefs/optional/junit
                        JUnitTask.java
               src/main/org/apache/tools/ant/taskdefs/rmic WLRmic.java
               src/main/org/apache/tools/ant/types Mapper.java
                        XMLCatalog.java
               src/main/org/apache/tools/ant/types/selectors
                        ExtendSelector.java
  Added:       src/main/org/apache/tools/ant/loader AntClassLoader2.java
  Log:
  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
  
  Revision  Changes    Path
  1.346     +3 -0      jakarta-ant/build.xml
  
  Index: build.xml
  ===================================================================
  RCS file: /home/cvs/jakarta-ant/build.xml,v
  retrieving revision 1.345
  retrieving revision 1.346
  diff -u -w -u -r1.345 -r1.346
  --- build.xml	24 Jan 2003 10:47:19 -0000	1.345
  +++ build.xml	24 Jan 2003 14:18:20 -0000	1.346
  @@ -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>
   
     <!--
  
  
  
  1.64      +116 -56   jakarta-ant/src/main/org/apache/tools/ant/AntClassLoader.java
  
  Index: AntClassLoader.java
  ===================================================================
  RCS file: /home/cvs/jakarta-ant/src/main/org/apache/tools/ant/AntClassLoader.java,v
  retrieving revision 1.63
  retrieving revision 1.64
  diff -u -w -u -r1.63 -r1.64
  --- AntClassLoader.java	24 Dec 2002 01:31:56 -0000	1.63
  +++ AntClassLoader.java	24 Jan 2003 14:18:20 -0000	1.64
  @@ -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 @@
        * @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.
            */
  @@ -268,6 +266,13 @@
   
   
       /**
  +     * Create an Ant Class Loader 
  +     */
  +    public AntClassLoader() {
  +        setParent(null);
  +    }
  +
  +    /**
        * Creates a classloader for the given project using the classpath given.
        *
        * @param project The project to which this classloader is to belong.
  @@ -279,21 +284,9 @@
        *                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 @@
                             boolean parentFirst) {
           this(project, classpath);
           if (parent != null) {
  -            this.parent = parent;
  +            setParent(parent);
           }
  -        this.parentFirst = parentFirst;
  +        setParentFirst(parentFirst);
           addJavaLibraries();
       }
   
  @@ -354,15 +347,68 @@
        *                    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.
        *
  @@ -834,7 +880,7 @@
       }
   
       /**
  -     * 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 @@
        * @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 @@
       }
   
       /**
  -     * 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());
  @@ -1020,6 +1050,36 @@
       }
   
       /**
  +     * 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.
        *
        * @param name The name of the class to be loaded. Must not be
  @@ -1063,7 +1123,7 @@
                       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;
  @@ -1187,7 +1247,7 @@
        * 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()) {
  
  
  
  1.125     +30 -1     jakarta-ant/src/main/org/apache/tools/ant/Project.java
  
  Index: Project.java
  ===================================================================
  RCS file: /home/cvs/jakarta-ant/src/main/org/apache/tools/ant/Project.java,v
  retrieving revision 1.124
  retrieving revision 1.125
  diff -u -w -u -r1.124 -r1.125
  --- Project.java	20 Jan 2003 12:44:24 -0000	1.124
  +++ Project.java	24 Jan 2003 14:18:20 -0000	1.125
  @@ -68,6 +68,7 @@
   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;
  @@ -275,6 +276,34 @@
           }
   
           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;
       }
   
       /**
  
  
  
  1.8       +2 -2      jakarta-ant/src/main/org/apache/tools/ant/filters/util/ChainReaderHelper.java
  
  Index: ChainReaderHelper.java
  ===================================================================
  RCS file: /home/cvs/jakarta-ant/src/main/org/apache/tools/ant/filters/util/ChainReaderHelper.java,v
  retrieving revision 1.7
  retrieving revision 1.8
  diff -u -w -u -r1.7 -r1.8
  --- ChainReaderHelper.java	4 Dec 2002 16:42:29 -0000	1.7
  +++ ChainReaderHelper.java	24 Jan 2003 14:18:20 -0000	1.8
  @@ -171,8 +171,8 @@
                               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);
                               }
  
  
  
  1.1                  jakarta-ant/src/main/org/apache/tools/ant/loader/AntClassLoader2.java
  
  Index: AntClassLoader2.java
  ===================================================================
  /*
   * 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);        
      }
  }
  
  
  
  
  1.52      +14 -13    jakarta-ant/src/main/org/apache/tools/ant/taskdefs/Available.java
  
  Index: Available.java
  ===================================================================
  RCS file: /home/cvs/jakarta-ant/src/main/org/apache/tools/ant/taskdefs/Available.java,v
  retrieving revision 1.51
  retrieving revision 1.52
  diff -u -w -u -r1.51 -r1.52
  --- Available.java	4 Dec 2002 16:42:29 -0000	1.51
  +++ Available.java	24 Jan 2003 14:18:20 -0000	1.52
  @@ -282,7 +282,7 @@
   
           if (classpath != null) {
               classpath.setProject(getProject());
  -            this.loader = new AntClassLoader(getProject(), classpath);
  +            this.loader = getProject().createClassLoader(classpath);
           }
   
           String appendix = "";
  @@ -464,8 +464,9 @@
           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);
  
  
  
  1.26      +13 -3     jakarta-ant/src/main/org/apache/tools/ant/taskdefs/Definer.java
  
  Index: Definer.java
  ===================================================================
  RCS file: /home/cvs/jakarta-ant/src/main/org/apache/tools/ant/taskdefs/Definer.java,v
  retrieving revision 1.25
  retrieving revision 1.26
  diff -u -w -u -r1.25 -r1.26
  --- Definer.java	6 Jan 2003 14:16:13 -0000	1.25
  +++ Definer.java	24 Jan 2003 14:18:20 -0000	1.26
  @@ -316,12 +316,22 @@
           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
  
  
  
  1.28      +9 -7      jakarta-ant/src/main/org/apache/tools/ant/taskdefs/ExecuteJava.java
  
  Index: ExecuteJava.java
  ===================================================================
  RCS file: /home/cvs/jakarta-ant/src/main/org/apache/tools/ant/taskdefs/ExecuteJava.java,v
  retrieving revision 1.27
  retrieving revision 1.28
  diff -u -w -u -r1.27 -r1.28
  --- ExecuteJava.java	25 Jul 2002 15:21:04 -0000	1.27
  +++ ExecuteJava.java	24 Jan 2003 14:18:20 -0000	1.28
  @@ -132,8 +132,10 @@
               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);
  
  
  
  1.8       +1 -1      jakarta-ant/src/main/org/apache/tools/ant/taskdefs/JDBCTask.java
  
  Index: JDBCTask.java
  ===================================================================
  RCS file: /home/cvs/jakarta-ant/src/main/org/apache/tools/ant/taskdefs/JDBCTask.java,v
  retrieving revision 1.7
  retrieving revision 1.8
  diff -u -w -u -r1.7 -r1.8
  --- JDBCTask.java	25 Jul 2002 15:21:04 -0000	1.7
  +++ JDBCTask.java	24 Jan 2003 14:18:20 -0000	1.8
  @@ -382,7 +382,7 @@
                           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.57      +1 -1      jakarta-ant/src/main/org/apache/tools/ant/taskdefs/Property.java
  
  Index: Property.java
  ===================================================================
  RCS file: /home/cvs/jakarta-ant/src/main/org/apache/tools/ant/taskdefs/Property.java,v
  retrieving revision 1.56
  retrieving revision 1.57
  diff -u -w -u -r1.56 -r1.57
  --- Property.java	13 Sep 2002 08:54:26 -0000	1.56
  +++ Property.java	24 Jan 2003 14:18:20 -0000	1.57
  @@ -413,7 +413,7 @@
               ClassLoader cL = null;
   
               if (classpath != null) {
  -                cL = new AntClassLoader(getProject(), classpath);
  +                cL = getProject().createClassLoader(classpath);
               } else {
                   cL = this.getClass().getClassLoader();
               }
  
  
  
  1.44      +58 -58    jakarta-ant/src/main/org/apache/tools/ant/taskdefs/Rmic.java
  
  Index: Rmic.java
  ===================================================================
  RCS file: /home/cvs/jakarta-ant/src/main/org/apache/tools/ant/taskdefs/Rmic.java,v
  retrieving revision 1.43
  retrieving revision 1.44
  diff -u -w -u -r1.43 -r1.44
  --- Rmic.java	9 Sep 2002 12:12:47 -0000	1.43
  +++ Rmic.java	24 Jan 2003 14:18:21 -0000	1.44
  @@ -492,7 +492,7 @@
           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
  
  
  
  1.56      +2 -2      jakarta-ant/src/main/org/apache/tools/ant/taskdefs/XSLTProcess.java
  
  Index: XSLTProcess.java
  ===================================================================
  RCS file: /home/cvs/jakarta-ant/src/main/org/apache/tools/ant/taskdefs/XSLTProcess.java,v
  retrieving revision 1.55
  retrieving revision 1.56
  diff -u -w -u -r1.55 -r1.56
  --- XSLTProcess.java	23 Dec 2002 11:50:52 -0000	1.55
  +++ XSLTProcess.java	24 Jan 2003 14:18:21 -0000	1.56
  @@ -418,7 +418,7 @@
           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;
  
  
  
  1.31      +4 -3      jakarta-ant/src/main/org/apache/tools/ant/taskdefs/optional/XMLValidateTask.java
  
  Index: XMLValidateTask.java
  ===================================================================
  RCS file: /home/cvs/jakarta-ant/src/main/org/apache/tools/ant/taskdefs/optional/XMLValidateTask.java,v
  retrieving revision 1.30
  retrieving revision 1.31
  diff -u -w -u -r1.30 -r1.31
  --- XMLValidateTask.java	27 Nov 2002 16:38:56 -0000	1.30
  +++ XMLValidateTask.java	24 Jan 2003 14:18:21 -0000	1.31
  @@ -321,7 +321,8 @@
               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 {
  
  
  
  1.33      +54 -55    jakarta-ant/src/main/org/apache/tools/ant/taskdefs/optional/depend/Depend.java
  
  Index: Depend.java
  ===================================================================
  RCS file: /home/cvs/jakarta-ant/src/main/org/apache/tools/ant/taskdefs/optional/depend/Depend.java,v
  retrieving revision 1.32
  retrieving revision 1.33
  diff -u -w -u -r1.32 -r1.33
  --- Depend.java	25 Jul 2002 15:21:12 -0000	1.32
  +++ Depend.java	24 Jan 2003 14:18:22 -0000	1.33
  @@ -393,8 +393,7 @@
           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();
  
  
  
  1.41      +2 -1      jakarta-ant/src/main/org/apache/tools/ant/taskdefs/optional/ejb/GenericDeploymentTool.java
  
  Index: GenericDeploymentTool.java
  ===================================================================
  RCS file: /home/cvs/jakarta-ant/src/main/org/apache/tools/ant/taskdefs/optional/ejb/GenericDeploymentTool.java,v
  retrieving revision 1.40
  retrieving revision 1.41
  diff -u -w -u -r1.40 -r1.41
  --- GenericDeploymentTool.java	25 Jul 2002 15:21:13 -0000	1.40
  +++ GenericDeploymentTool.java	24 Jan 2003 14:18:22 -0000	1.41
  @@ -924,7 +924,8 @@
           if (combinedClasspath == null) {
               classpathLoader = getClass().getClassLoader();
           } else {
  -            classpathLoader = new AntClassLoader(getTask().getProject(), combinedClasspath);
  +            classpathLoader
  +                = getTask().getProject().createClassLoader(combinedClasspath);
           }
   
           return classpathLoader;
  
  
  
  1.8       +287 -287  jakarta-ant/src/main/org/apache/tools/ant/taskdefs/optional/ejb/JonasDeploymentTool.java
  
  Index: JonasDeploymentTool.java
  ===================================================================
  RCS file: /home/cvs/jakarta-ant/src/main/org/apache/tools/ant/taskdefs/optional/ejb/JonasDeploymentTool.java,v
  retrieving revision 1.7
  retrieving revision 1.8
  diff -u -w -u -r1.7 -r1.8
  --- JonasDeploymentTool.java	8 Nov 2002 16:37:44 -0000	1.7
  +++ JonasDeploymentTool.java	24 Jan 2003 14:18:22 -0000	1.8
  @@ -700,7 +700,7 @@
   
   	log("Looking for GenIC class in classpath: " + classpath.toString(), Project.MSG_VERBOSE);
   
  -	AntClassLoader cl = new AntClassLoader(classpath.getProject(), classpath);
  +        AntClassLoader cl = classpath.getProject().createClassLoader(classpath);
   
   	try {
   	    cl.loadClass(JonasDeploymentTool.GENIC_CLASS);
  
  
  
  1.45      +1 -1      jakarta-ant/src/main/org/apache/tools/ant/taskdefs/optional/ejb/WeblogicDeploymentTool.java
  
  Index: WeblogicDeploymentTool.java
  ===================================================================
  RCS file: /home/cvs/jakarta-ant/src/main/org/apache/tools/ant/taskdefs/optional/ejb/WeblogicDeploymentTool.java,v
  retrieving revision 1.44
  retrieving revision 1.45
  diff -u -w -u -r1.44 -r1.45
  --- WeblogicDeploymentTool.java	25 Jul 2002 15:21:14 -0000	1.44
  +++ WeblogicDeploymentTool.java	24 Jan 2003 14:18:22 -0000	1.45
  @@ -891,7 +891,7 @@
               lookupPath.append(classpath);
           }
   
  -        return new AntClassLoader(getTask().getProject(), lookupPath);
  +        return getTask().getProject().createClassLoader(lookupPath);
       }
   }
   
  
  
  
  1.15      +7 -7      jakarta-ant/src/main/org/apache/tools/ant/taskdefs/optional/ejb/WebsphereDeploymentTool.java
  
  Index: WebsphereDeploymentTool.java
  ===================================================================
  RCS file: /home/cvs/jakarta-ant/src/main/org/apache/tools/ant/taskdefs/optional/ejb/WebsphereDeploymentTool.java,v
  retrieving revision 1.14
  retrieving revision 1.15
  diff -u -w -u -r1.14 -r1.15
  --- WebsphereDeploymentTool.java	15 Aug 2002 22:00:27 -0000	1.14
  +++ WebsphereDeploymentTool.java	24 Jan 2003 14:18:22 -0000	1.15
  @@ -922,7 +922,7 @@
               lookupPath.append(classpath);
           }
   
  -        return new AntClassLoader(getTask().getProject(), lookupPath);
  +        return getTask().getProject().createClassLoader(lookupPath);
       }
   }
   
  
  
  
  1.26      +4 -4      jakarta-ant/src/main/org/apache/tools/ant/taskdefs/optional/jsp/JspC.java
  
  Index: JspC.java
  ===================================================================
  RCS file: /home/cvs/jakarta-ant/src/main/org/apache/tools/ant/taskdefs/optional/jsp/JspC.java,v
  retrieving revision 1.25
  retrieving revision 1.26
  diff -u -w -u -r1.25 -r1.26
  --- JspC.java	10 Aug 2002 07:04:28 -0000	1.25
  +++ JspC.java	24 Jan 2003 14:18:23 -0000	1.26
  @@ -415,7 +415,7 @@
           //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) {
  
  
  
  1.4       +3 -3      jakarta-ant/src/main/org/apache/tools/ant/taskdefs/optional/jsp/compilers/JspCompilerAdapterFactory.java
  
  Index: JspCompilerAdapterFactory.java
  ===================================================================
  RCS file: /home/cvs/jakarta-ant/src/main/org/apache/tools/ant/taskdefs/optional/jsp/compilers/JspCompilerAdapterFactory.java,v
  retrieving revision 1.3
  retrieving revision 1.4
  diff -u -w -u -r1.3 -r1.4
  --- JspCompilerAdapterFactory.java	5 Jun 2002 21:02:01 -0000	1.3
  +++ JspCompilerAdapterFactory.java	24 Jan 2003 14:18:23 -0000	1.4
  @@ -89,7 +89,7 @@
       public static JspCompilerAdapter getCompiler(String compilerType, Task task)
           throws BuildException {
           return getCompiler(compilerType, task, 
  -                           new AntClassLoader(task.getProject(), null));
  +                           task.getProject().createClassLoader(null));
       }
   
       /**
  
  
  
  1.52      +24 -22    jakarta-ant/src/main/org/apache/tools/ant/taskdefs/optional/junit/JUnitTask.java
  
  Index: JUnitTask.java
  ===================================================================
  RCS file: /home/cvs/jakarta-ant/src/main/org/apache/tools/ant/taskdefs/optional/junit/JUnitTask.java,v
  retrieving revision 1.51
  retrieving revision 1.52
  diff -u -w -u -r1.51 -r1.52
  --- JUnitTask.java	7 Nov 2002 07:50:08 -0000	1.51
  +++ JUnitTask.java	24 Jan 2003 14:18:23 -0000	1.52
  @@ -770,7 +770,9 @@
                       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);
   
  
  
  
  1.12      +2 -2      jakarta-ant/src/main/org/apache/tools/ant/taskdefs/rmic/WLRmic.java
  
  Index: WLRmic.java
  ===================================================================
  RCS file: /home/cvs/jakarta-ant/src/main/org/apache/tools/ant/taskdefs/rmic/WLRmic.java,v
  retrieving revision 1.11
  retrieving revision 1.12
  diff -u -w -u -r1.11 -r1.12
  --- WLRmic.java	25 Jul 2002 15:21:21 -0000	1.11
  +++ WLRmic.java	24 Jan 2003 14:18:23 -0000	1.12
  @@ -79,8 +79,8 @@
               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);
               }
  
  
  
  1.13      +14 -15    jakarta-ant/src/main/org/apache/tools/ant/types/Mapper.java
  
  Index: Mapper.java
  ===================================================================
  RCS file: /home/cvs/jakarta-ant/src/main/org/apache/tools/ant/types/Mapper.java,v
  retrieving revision 1.12
  retrieving revision 1.13
  diff -u -w -u -r1.12 -r1.13
  --- Mapper.java	25 Jul 2002 15:21:21 -0000	1.12
  +++ Mapper.java	24 Jan 2003 14:18:23 -0000	1.13
  @@ -198,8 +198,7 @@
               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);
               }
  
  
  
  1.23      +41 -41    jakarta-ant/src/main/org/apache/tools/ant/types/XMLCatalog.java
  
  Index: XMLCatalog.java
  ===================================================================
  RCS file: /home/cvs/jakarta-ant/src/main/org/apache/tools/ant/types/XMLCatalog.java,v
  retrieving revision 1.22
  retrieving revision 1.23
  diff -u -w -u -r1.22 -r1.23
  --- XMLCatalog.java	17 Jan 2003 14:34:55 -0000	1.22
  +++ XMLCatalog.java	24 Jan 2003 14:18:23 -0000	1.23
  @@ -521,7 +521,7 @@
   
               AntClassLoader loader = null;
   
  -            loader = new AntClassLoader(getProject(), Path.systemClasspath);
  +            loader = getProject().createClassLoader(Path.systemClasspath);
   
               try {
                   Class clazz = loader.forceLoadSystemClass(APACHE_RESOLVER);
  @@ -707,7 +707,7 @@
           } else {
               cp = (new Path(getProject())).concatSystemClasspath("last");
           }
  -        loader = new AntClassLoader(getProject(), cp);
  +        loader = getProject().createClassLoader(cp);
   
           //
           // for classpath lookup we ignore the base directory
  
  
  
  1.4       +2 -2      jakarta-ant/src/main/org/apache/tools/ant/types/selectors/ExtendSelector.java
  
  Index: ExtendSelector.java
  ===================================================================
  RCS file: /home/cvs/jakarta-ant/src/main/org/apache/tools/ant/types/selectors/ExtendSelector.java,v
  retrieving revision 1.3
  retrieving revision 1.4
  diff -u -w -u -r1.3 -r1.4
  --- ExtendSelector.java	25 Jul 2002 15:21:23 -0000	1.3
  +++ ExtendSelector.java	24 Jan 2003 14:18:23 -0000	1.4
  @@ -100,8 +100,8 @@
                   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);
                   }
  
  
  

--
To unsubscribe, e-mail:   <ma...@jakarta.apache.org>
For additional commands, e-mail: <ma...@jakarta.apache.org>