Index: CompilerAdapterFactory.java
===================================================================
RCS file: /home/cvs/jakarta-ant/src/main/org/apache/tools/ant/taskdefs/compilers/CompilerAdapterFactory.java,v
retrieving revision 1.5
diff -u -r1.5 CompilerAdapterFactory.java
--- CompilerAdapterFactory.java	7 Aug 2001 11:53:43 -0000	1.5
+++ CompilerAdapterFactory.java	4 Apr 2002 04:54:06 -0000
@@ -1,7 +1,7 @@
 /*
  * The Apache Software License, Version 1.1
  *
- * Copyright (c) 2001 The Apache Software Foundation.  All rights
+ * Copyright (c) 2001-2002 The Apache Software Foundation.  All rights
  * reserved.
  *
  * Redistribution and use in source and binary forms, with or without
@@ -65,7 +65,7 @@
  */
 public class CompilerAdapterFactory {
 
-    /** This is a singlton -- can't create instances!! */
+    /** This is a singleton -- can't create instances!! */
     private CompilerAdapterFactory() {
     }
 
@@ -94,6 +94,12 @@
      */
     public static CompilerAdapter getCompiler( String compilerType, Task task ) 
         throws BuildException {
+            boolean isClassicCompilerSupported=true;
+            //as new versions of java come out, add them to this test
+            if(Project.getJavaVersion()==Project.JAVA_1_4) {
+                 isClassicCompilerSupported=false;
+             }
+
             /* If I've done things right, this should be the extent of the
              * conditional statements required.
              */
@@ -106,20 +112,36 @@
             if ( compilerType.equalsIgnoreCase("classic") ||
                     compilerType.equalsIgnoreCase("javac1.1") ||
                     compilerType.equalsIgnoreCase("javac1.2")) {
-                return new Javac12();
+                if(isClassicCompilerSupported) {
+                    return new Javac12();
+                }
+                else {
+                    throw new BuildException("This version of java does "
+                                             +"not support the classic compiler");
+                }
+
             }
+            //on java<=1.3 the modern falls back to classic if it is not found
+            //but on java>=1.4 we just bail out early
             if ( compilerType.equalsIgnoreCase("modern") ||
                     compilerType.equalsIgnoreCase("javac1.3") ||
                     compilerType.equalsIgnoreCase("javac1.4")) {
                 // does the modern compiler exist?
-                try {
-                    Class.forName("com.sun.tools.javac.Main");
-                } catch (ClassNotFoundException cnfe) {
-                    task.log("Modern compiler is not available - using "
-                            + "classic compiler", Project.MSG_WARN);
-                    return new Javac12();
+                if(doesModernCompilerExist()) {
+                    return new Javac13();
+                } else {
+                    if(isClassicCompilerSupported) {
+                        task.log("Modern compiler not found - looking for "
+                                + "classic compiler", Project.MSG_WARN);
+                        return new Javac12();
+                    }
+                    else {
+                        throw new BuildException("Unable to find a javac compiler;\n"
+                                                 +"com.sun.tools.javac.Main is not on the classpath.\n"
+                                                 +"Perhaps JAVA_HOME does not point to the JDK");
+                    }
                 }
-                return new Javac13();
+                
             }
             if ( compilerType.equalsIgnoreCase("jvc") ||
                     compilerType.equalsIgnoreCase("microsoft")) {
@@ -138,6 +160,19 @@
             return resolveClassName( compilerType );
         }
 
+    /**
+     * query for the Modern compiler existing
+     * @return true iff classic os on the classpath
+     */ 
+    private static boolean doesModernCompilerExist() {
+        try {
+            Class.forName("com.sun.tools.javac.Main");
+            return true;
+        } catch (ClassNotFoundException cnfe) {
+            return false;
+        }
+    }
+    
     /**
      * Tries to resolve the given classname into a compiler adapter.
      * Throws a fit if it can't.

