diff --git a/src/main/org/apache/tools/ant/IntrospectionHelper.java b/src/main/org/apache/tools/ant/IntrospectionHelper.java
index b444edcee..a0792f940 100644
--- a/src/main/org/apache/tools/ant/IntrospectionHelper.java
+++ b/src/main/org/apache/tools/ant/IntrospectionHelper.java
@@ -257,7 +257,7 @@ public class IntrospectionHelper implements BuildListener {
particular order.
*/
}
- AttributeSetter as = createAttributeSetter(m, args[0]);
+ AttributeSetter as = createAttributeSetter(m, args[0], propName);
if (as != null) {
attributeTypes.put(propName, args[0]);
attributeSetters.put(propName, as);
@@ -723,12 +723,15 @@ public class IntrospectionHelper implements BuildListener {
* Must not be null
.
* @param arg The type of the single argument of the bean's method.
* Must not be null
.
+ * @param attrName the name of the attribute for which the setter is being
+ * created.
*
* @return an appropriate AttributeSetter instance, or null
* if no appropriate conversion is available.
*/
private AttributeSetter createAttributeSetter(final Method m,
- Class arg) {
+ Class arg,
+ final String attrName) {
// use wrappers for primitive classes, e.g. int and
// Integer are treated identically
final Class reflectedArg = PRIMITIVE_TYPE_MAP.containsKey (arg)
@@ -748,6 +751,11 @@ public class IntrospectionHelper implements BuildListener {
return new AttributeSetter() {
public void set(Project p, Object parent, String value)
throws InvocationTargetException, IllegalAccessException {
+ if (value.length() == 0) {
+ throw new BuildException("The value \"\" is not a "
+ + "legal value for attribute \""
+ + attrName + "\"");
+ }
m.invoke(parent, new Character[] {new Character(value.charAt(0))});
}
diff --git a/src/main/org/apache/tools/ant/filters/ReplaceTokens.java b/src/main/org/apache/tools/ant/filters/ReplaceTokens.java
index 671d0da67..92c547e37 100644
--- a/src/main/org/apache/tools/ant/filters/ReplaceTokens.java
+++ b/src/main/org/apache/tools/ant/filters/ReplaceTokens.java
@@ -1,7 +1,7 @@
/*
* The Apache Software License, Version 1.1
*
- * Copyright (c) 2002 The Apache Software Foundation. All rights
+ * Copyright (c) 2002-2003 The Apache Software Foundation. All rights
* reserved.
*
* Redistribution and use in source and binary forms, with or without
@@ -57,6 +57,7 @@ import java.io.IOException;
import java.io.Reader;
import java.util.Hashtable;
import org.apache.tools.ant.types.Parameter;
+import org.apache.tools.ant.BuildException;
/**
* Replaces tokens in the original input with user-supplied values.
@@ -303,9 +304,18 @@ public final class ReplaceTokens
final String type = params[i].getType();
if ("tokenchar".equals(type)) {
final String name = params[i].getName();
+ String value = params[i].getValue();
if ("begintoken".equals(name)) {
+ if (value.length() == 0) {
+ throw new BuildException("Begin token cannot "
+ + "be empty");
+ }
beginToken = params[i].getValue().charAt(0);
} else if ("endtoken".equals(name)) {
+ if (value.length() == 0) {
+ throw new BuildException("End token cannot "
+ + "be empty");
+ }
endToken = params[i].getValue().charAt(0);
}
} else if ("token".equals(type)) {