ant-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From jgl...@apache.org
Subject svn commit: r432728 - in /ant/core/trunk/src/main/org/apache/tools/ant/util/regexp: RegexpFactory.java RegexpMatcherFactory.java
Date Fri, 18 Aug 2006 21:21:55 GMT
Author: jglick
Date: Fri Aug 18 14:21:54 2006
New Revision: 432728

URL: http://svn.apache.org/viewvc?rev=432728&view=rev
Log:
Providing more information in case a regexp impl is unavailable for unexpected reasons.

Modified:
    ant/core/trunk/src/main/org/apache/tools/ant/util/regexp/RegexpFactory.java
    ant/core/trunk/src/main/org/apache/tools/ant/util/regexp/RegexpMatcherFactory.java

Modified: ant/core/trunk/src/main/org/apache/tools/ant/util/regexp/RegexpFactory.java
URL: http://svn.apache.org/viewvc/ant/core/trunk/src/main/org/apache/tools/ant/util/regexp/RegexpFactory.java?rev=432728&r1=432727&r2=432728&view=diff
==============================================================================
--- ant/core/trunk/src/main/org/apache/tools/ant/util/regexp/RegexpFactory.java (original)
+++ ant/core/trunk/src/main/org/apache/tools/ant/util/regexp/RegexpFactory.java Fri Aug 18
14:21:54 2006
@@ -18,6 +18,7 @@
 
 import org.apache.tools.ant.BuildException;
 import org.apache.tools.ant.Project;
+import org.apache.tools.ant.util.JavaEnvUtils;
 
 /***
  * Regular expression factory, which will create Regexp objects.  The
@@ -61,28 +62,31 @@
             //         load a different implementation?
         }
 
+        Throwable cause = null;
+
         try {
             testAvailability("java.util.regex.Matcher");
             return createRegexpInstance("org.apache.tools.ant.util.regexp.Jdk14RegexpRegexp");
         } catch (BuildException be) {
-            // ignore
+            cause = orCause(cause, be, JavaEnvUtils.getJavaVersionNumber() < 14);
         }
 
         try {
             testAvailability("org.apache.oro.text.regex.Pattern");
             return createRegexpInstance("org.apache.tools.ant.util.regexp.JakartaOroRegexp");
         } catch (BuildException be) {
-            // ignore
+            cause = orCause(cause, be, true);
         }
 
         try {
             testAvailability("org.apache.regexp.RE");
             return createRegexpInstance("org.apache.tools.ant.util.regexp.JakartaRegexpRegexp");
         } catch (BuildException be) {
-            // ignore
+            cause = orCause(cause, be, true);
         }
 
-        throw new BuildException("No supported regular expression matcher found");
+        throw new BuildException("No supported regular expression matcher found" +
+                (cause != null ? ": " + cause : ""), cause);
     }
 
     /**

Modified: ant/core/trunk/src/main/org/apache/tools/ant/util/regexp/RegexpMatcherFactory.java
URL: http://svn.apache.org/viewvc/ant/core/trunk/src/main/org/apache/tools/ant/util/regexp/RegexpMatcherFactory.java?rev=432728&r1=432727&r2=432728&view=diff
==============================================================================
--- ant/core/trunk/src/main/org/apache/tools/ant/util/regexp/RegexpMatcherFactory.java (original)
+++ ant/core/trunk/src/main/org/apache/tools/ant/util/regexp/RegexpMatcherFactory.java Fri
Aug 18 14:21:54 2006
@@ -21,6 +21,7 @@
 import org.apache.tools.ant.MagicNames;
 import org.apache.tools.ant.BuildException;
 import org.apache.tools.ant.util.ClasspathUtils;
+import org.apache.tools.ant.util.JavaEnvUtils;
 
 /**
  * Simple Factory Class that produces an implementation of
@@ -69,29 +70,40 @@
             //         load a different implementation?
         }
 
+        Throwable cause = null;
+
         try {
             testAvailability("java.util.regex.Matcher");
             return createInstance("org.apache.tools.ant.util.regexp.Jdk14RegexpMatcher");
         } catch (BuildException be) {
-            // ignore
+            cause = orCause(cause, be, JavaEnvUtils.getJavaVersionNumber() < 14);
         }
 
         try {
             testAvailability("org.apache.oro.text.regex.Pattern");
             return createInstance("org.apache.tools.ant.util.regexp.JakartaOroMatcher");
         } catch (BuildException be) {
-            // ignore
+            cause = orCause(cause, be, true);
         }
 
         try {
             testAvailability("org.apache.regexp.RE");
             return createInstance("org.apache.tools.ant.util.regexp.JakartaRegexpMatcher");
         } catch (BuildException be) {
-            // ignore
+            cause = orCause(cause, be, true);
         }
 
-        throw new BuildException("No supported regular expression matcher found");
+        throw new BuildException("No supported regular expression matcher found" +
+                (cause != null ? ": " + cause : ""), cause);
    }
+
+    static Throwable orCause(Throwable deflt, BuildException be, boolean ignoreCnfe) {
+        if (deflt != null) {
+            return deflt;
+        }
+        Throwable t = be.getException();
+        return ignoreCnfe && t instanceof ClassNotFoundException ? null : t;
+    }
 
     /**
      * Create an instance of a matcher from a classname.



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


Mime
View raw message