ant-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From co...@apache.org
Subject cvs commit: jakarta-ant/src/main/org/apache/tools/ant/types Mapper.java
Date Thu, 10 May 2001 15:23:04 GMT
conor       01/05/10 08:23:03

  Modified:    src/main/org/apache/tools/ant AntClassLoader.java Main.java
               src/main/org/apache/tools/ant/taskdefs ExecuteJava.java
                        Taskdef.java
               src/main/org/apache/tools/ant/taskdefs/optional
                        XMLValidateTask.java
               src/main/org/apache/tools/ant/taskdefs/optional/junit
                        JUnitTestRunner.java
               src/main/org/apache/tools/ant/types Mapper.java
  Log:
  Initialize classes which are loaded through a classloader. Note that the
  approach here uses newInstance to achieve initialisation for JDK 1.1
  compatability. Under JDK 1.2, both initialization and the classloader to
  use can be specified to Class.forName();
  
  Revision  Changes    Path
  1.18      +16 -1     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.17
  retrieving revision 1.18
  diff -u -r1.17 -r1.18
  --- AntClassLoader.java	2001/05/09 15:14:46	1.17
  +++ AntClassLoader.java	2001/05/10 15:22:38	1.18
  @@ -159,7 +159,22 @@
       public void setIsolated(boolean isolated) {
           ignoreBase = isolated;
       }
  -    
  +
  +    /**
  +     * Force initialization of a class in a JDK 1.1 compatible, albeit hacky 
  +     * way 
  +     */
  +    static public void initializeClass(Class theClass) {
  +        // ***HACK*** We try to create an instance to force the VM to run the
  +        // class' static initializer. We don't care if the instance can't 
  +        // be created - we are just interested in the side effect.
  +        try {
  +            theClass.newInstance();
  +        }
  +        catch (Exception e) {
  +            //ignore - our work is done
  +        }
  +    }
       
       /**
        * Add a package root to the list of packages which must be loaded on the 
  
  
  
  1.34      +1 -1      jakarta-ant/src/main/org/apache/tools/ant/Main.java
  
  Index: Main.java
  ===================================================================
  RCS file: /home/cvs/jakarta-ant/src/main/org/apache/tools/ant/Main.java,v
  retrieving revision 1.33
  retrieving revision 1.34
  diff -u -r1.33 -r1.34
  --- Main.java	2001/03/16 14:27:12	1.33
  +++ Main.java	2001/05/10 15:22:41	1.34
  @@ -382,8 +382,8 @@
   
           try {
               addBuildListeners(project);
  -            project.fireBuildStarted();
   
  +            project.fireBuildStarted();
               project.init();
   
               // set user-define properties
  
  
  
  1.9       +1 -0      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.8
  retrieving revision 1.9
  diff -u -r1.8 -r1.9
  --- ExecuteJava.java	2001/02/18 13:44:42	1.8
  +++ ExecuteJava.java	2001/05/10 15:22:46	1.9
  @@ -122,6 +122,7 @@
                   AntClassLoader loader = new AntClassLoader(project, classpath, false);
                   loader.setIsolated(true);
                   target = loader.forceLoadClass(classname);
  +                AntClassLoader.initializeClass(target);
               }
               final Method main = target.getMethod("main", param);
               main.invoke(null, argument);
  
  
  
  1.14      +1 -0      jakarta-ant/src/main/org/apache/tools/ant/taskdefs/Taskdef.java
  
  Index: Taskdef.java
  ===================================================================
  RCS file: /home/cvs/jakarta-ant/src/main/org/apache/tools/ant/taskdefs/Taskdef.java,v
  retrieving revision 1.13
  retrieving revision 1.14
  diff -u -r1.13 -r1.14
  --- Taskdef.java	2001/01/03 14:18:31	1.13
  +++ Taskdef.java	2001/05/10 15:22:47	1.14
  @@ -109,6 +109,7 @@
               Class taskClass = null;
               if (loader != null) {
                   taskClass = loader.loadClass(value);
  +                AntClassLoader.initializeClass(taskClass);
               } else {
                   taskClass = Class.forName(value);
               }
  
  
  
  1.3       +1 -1      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.2
  retrieving revision 1.3
  diff -u -r1.2 -r1.3
  --- XMLValidateTask.java	2001/05/10 11:44:06	1.2
  +++ XMLValidateTask.java	2001/05/10 15:22:51	1.3
  @@ -265,7 +265,7 @@
                   AntClassLoader loader = new AntClassLoader(project, classpath, false);
                   loader.addSystemPackageRoot("org.xml"); // needed to avoid conflict
                   readerClass = loader.loadClass(readerClassName);
  -                //readerImpl  = loader.loadClass(
  +                AntClassLoader.initializeClass(readerClass);
               } else 
                   readerClass = Class.forName(readerClassName);
               
  
  
  
  1.9       +2 -2      jakarta-ant/src/main/org/apache/tools/ant/taskdefs/optional/junit/JUnitTestRunner.java
  
  Index: JUnitTestRunner.java
  ===================================================================
  RCS file: /home/cvs/jakarta-ant/src/main/org/apache/tools/ant/taskdefs/optional/junit/JUnitTestRunner.java,v
  retrieving revision 1.8
  retrieving revision 1.9
  diff -u -r1.8 -r1.9
  --- JUnitTestRunner.java	2001/05/03 15:03:59	1.8
  +++ JUnitTestRunner.java	2001/05/10 15:22:55	1.9
  @@ -54,8 +54,7 @@
   
   package org.apache.tools.ant.taskdefs.optional.junit;
   
  -import org.apache.tools.ant.BuildException;
  -import org.apache.tools.ant.Project;
  +import org.apache.tools.ant.*;
   
   import junit.framework.*;
   import java.lang.reflect.*;
  @@ -159,6 +158,7 @@
                   testClass = Class.forName(test.getName());
               } else {
                   testClass = loader.loadClass(test.getName());
  +                AntClassLoader.initializeClass(testClass);
               }
               
               Method suiteMethod = null;
  
  
  
  1.5       +1 -0      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.4
  retrieving revision 1.5
  diff -u -r1.4 -r1.5
  --- Mapper.java	2001/03/02 16:00:43	1.4
  +++ Mapper.java	2001/05/10 15:23:00	1.5
  @@ -203,6 +203,7 @@
               } else {
                   AntClassLoader al = new AntClassLoader(p, classpath);
                   c = al.loadClass(classname);
  +                AntClassLoader.initializeClass(c);
               }
               
               FileNameMapper m = (FileNameMapper) c.newInstance();
  
  
  

Mime
View raw message