conor       01/02/17 06:52:48

  Modified:    src/main/org/apache/tools/ant Tag: ANT_13_BRANCH
                        AntClassLoader.java
               src/main/org/apache/tools/ant/taskdefs Tag: ANT_13_BRANCH
                        ExecuteJava.java
  Log:
  If a classpath is given to a java task, it is now used exclusively. So if a
  class exists on the base class loader and not on the given classpath,
  a ClassNotFoundException will be raised. The java.* and javax.* hierarchies
  are exempt.
  
  Setting build.sysclasspath="first" or "last" will still allow the system
  classpath be picked up.
  
  PR:   630
  
  Revision  Changes    Path
  No                   revision
  
  
  No                   revision
  
  
  1.14.2.1  +19 -0     
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.14
  retrieving revision 1.14.2.1
  diff -u -r1.14 -r1.14.2.1
  --- AntClassLoader.java       2001/02/04 02:34:28     1.14
  +++ AntClassLoader.java       2001/02/17 14:52:47     1.14.2.1
  @@ -103,6 +103,12 @@
        */
       private Vector loaderPackages = new Vector();
       
  +    /**
  +     * This flag indicates that the classloader will ignore the base
  +     * classloader if it can;t find a class.
  +     */
  +    private boolean ignoreBase = false;
  +    
       private static Method getProtectionDomain = null;
       private static Method defineClassProtectionDomain = null;
       static {
  @@ -143,7 +149,17 @@
           this(project, classpath);
           this.systemFirst = systemFirst;
       }
  +
  +    /**
  +     * Set this classloader to run in isolated mode. In isolated mode, 
classes not
  +     * found on the given classpath will not be referred to the base class 
loader
  +     * but will cause a classNotFoundException.
  +     */
  +    public void setIsolated(boolean isolated) {
  +        ignoreBase = isolated;
  +    }
       
  +    
       /**
        * Add a package root to the list of packages which must be loaded on 
the 
        * system loader.
  @@ -354,6 +370,9 @@
                       project.log("Class " + classname + " loaded from ant 
loader", Project.MSG_DEBUG);
                   }
                   catch (ClassNotFoundException cnfe) {
  +                    if (ignoreBase) {
  +                        throw cnfe;
  +                    }
                       theClass = findBaseClass(classname);
                       project.log("Class " + classname + " loaded from system 
loader", Project.MSG_DEBUG);
                   }
  
  
  
  No                   revision
  
  
  No                   revision
  
  
  1.7.2.1   +2 -1      
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.7
  retrieving revision 1.7.2.1
  diff -u -r1.7 -r1.7.2.1
  --- ExecuteJava.java  2001/01/03 14:18:30     1.7
  +++ ExecuteJava.java  2001/02/17 14:52:47     1.7.2.1
  @@ -119,7 +119,8 @@
               if (classpath == null) {
                   target = Class.forName(classname);
               } else {
  -                AntClassLoader loader = new AntClassLoader(project, 
classpath);
  +                AntClassLoader loader = new AntClassLoader(project, 
classpath, false);
  +                loader.setIsolated(true);
                   target = loader.forceLoadClass(classname);
               }
               final Method main = target.getMethod("main", param);
  
  
  

Reply via email to