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/taskdefs Available.java
Date Mon, 11 Mar 2002 11:53:29 GMT
conor       02/03/11 03:53:29

  Modified:    src/main/org/apache/tools/ant/taskdefs Available.java
  Log:
  When Available checks for a class make sure the class can actually be
  used and not just loaded.
  
  Revision  Changes    Path
  1.35      +10 -4     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.34
  retrieving revision 1.35
  diff -u -w -u -r1.34 -r1.35
  --- Available.java	3 Mar 2002 01:46:20 -0000	1.34
  +++ Available.java	11 Mar 2002 11:53:29 -0000	1.35
  @@ -74,7 +74,6 @@
    *
    * @ant.task category="control"
    */
  -
   public class Available extends Task implements Condition {
   
       private String property;
  @@ -349,22 +348,29 @@
   
       private boolean checkClass(String classname) {
           try {
  +            Class requiredClass = null;
               if (loader != null) {
  -                loader.loadClass(classname);
  +                requiredClass = loader.loadClass(classname);
               } else {
                   ClassLoader l = this.getClass().getClassLoader();
                   // Can return null to represent the bootstrap class loader.
                   // see API docs of Class.getClassLoader.
                   if (l != null) {
  -                    l.loadClass(classname);
  +                    requiredClass = l.loadClass(classname);
                   } else {
  -                    Class.forName(classname);
  +                    requiredClass = Class.forName(classname);
                   }
               }
  +            AntClassLoader.initializeClass(requiredClass);
               return true;
           } catch (ClassNotFoundException e) {
  +            log("class \"" + classname + "\" was not found", 
  +                Project.MSG_DEBUG);
               return false;
           } catch (NoClassDefFoundError e) {
  +            log("Could not load dependent class \"" + e.getMessage() 
  +                + "\" for class \"" + classname + "\"", 
  +                Project.MSG_DEBUG);
               return false;
           }
       }
  
  
  

--
To unsubscribe, e-mail:   <mailto:ant-dev-unsubscribe@jakarta.apache.org>
For additional commands, e-mail: <mailto:ant-dev-help@jakarta.apache.org>


Mime
View raw message