You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@tomcat.apache.org by du...@hyperreal.org on 1999/11/01 00:14:16 UTC

cvs commit: jakarta-tools/ant/src/main/org/apache/tools/ant Project.java

duncan      99/10/31 15:14:15

  Modified:    .        ant.jar
               ant/src/main/org/apache/tools/ant Project.java
  Log:
  Tweaked java version detection logic to execute up front and report the
  version of Java in use by the runtime.
  
  Revision  Changes    Path
  1.11      +57 -57    jakarta-tools/ant.jar
  
  	<<Binary file>>
  
  
  1.7       +10 -6     jakarta-tools/ant/src/main/org/apache/tools/ant/Project.java
  
  Index: Project.java
  ===================================================================
  RCS file: /home/cvs/jakarta-tools/ant/src/main/org/apache/tools/ant/Project.java,v
  retrieving revision 1.6
  retrieving revision 1.7
  diff -u -r1.6 -r1.7
  --- Project.java	1999/10/31 23:06:37	1.6
  +++ Project.java	1999/10/31 23:14:14	1.7
  @@ -41,6 +41,7 @@
       private File baseDir;
       
       public Project() {
  +        detectJavaVersion();
   	String defs = "/org/apache/tools/ant/taskdefs/defaults.properties";
   	try {
   	    Properties props = new Properties();
  @@ -126,15 +127,17 @@
       
   
       public static String getJavaVersion() {
  -        if (javaVersion != null) {
  -            return javaVersion;
  -        }
  +        return javaVersion;
  +    }
  +
  +    private void detectJavaVersion() {
   
           // Determine the Java version by looking at available classes
           // java.lang.StrictMath was introduced in JDK 1.3
           // java.lang.ThreadLocal was introduced in JDK 1.2
           // java.lang.Void was introduced in JDK 1.1
           // Count up version until a NoClassDefFoundError ends the try
  +
           try {
               javaVersion = "1.0";
               Class.forName("java.lang.Void");
  @@ -144,10 +147,11 @@
               Class.forName("java.lang.StrictMath");
               javaVersion = "1.3";
           }
  -        catch (Throwable t) {
  +        catch (ClassNotFoundException cnfe) {
  +            // swallow as we've hit the max class version that
  +            // we have
           }
  -
  -        return javaVersion;
  +        log("Detected Java Version: " + javaVersion);
       }
   
       public void addTaskDefinition(String taskName, Class taskClass) {