diff --git a/src/main/org/apache/tools/ant/Project.java b/src/main/org/apache/tools/ant/Project.java index f310f1cc5..af621222d 100644 --- a/src/main/org/apache/tools/ant/Project.java +++ b/src/main/org/apache/tools/ant/Project.java @@ -830,8 +830,8 @@ public class Project { Properties systemP = System.getProperties(); Enumeration e = systemP.propertyNames(); while (e.hasMoreElements()) { - Object name = e.nextElement(); - String value = systemP.get(name).toString(); + String name = (String) e.nextElement(); + String value = systemP.getProperty(name); this.setPropertyInternal(name.toString(), value); } } diff --git a/src/main/org/apache/tools/ant/types/CommandlineJava.java b/src/main/org/apache/tools/ant/types/CommandlineJava.java index 882f09025..7c92ca2f8 100644 --- a/src/main/org/apache/tools/ant/types/CommandlineJava.java +++ b/src/main/org/apache/tools/ant/types/CommandlineJava.java @@ -134,8 +134,8 @@ public class CommandlineJava implements Cloneable { sys = System.getProperties(); Properties p = new Properties(); for (Enumeration e = sys.propertyNames(); e.hasMoreElements();) { - Object o = e.nextElement(); - p.put(o, sys.get(o)); + String name = (String) e.nextElement(); + p.put(name, sys.getProperty(name)); } p.putAll(mergePropertySets()); for (Enumeration e = variables.elements(); e.hasMoreElements();) { diff --git a/src/main/org/apache/tools/ant/types/PropertySet.java b/src/main/org/apache/tools/ant/types/PropertySet.java index 81955bf49..e31ef019c 100644 --- a/src/main/org/apache/tools/ant/types/PropertySet.java +++ b/src/main/org/apache/tools/ant/types/PropertySet.java @@ -173,6 +173,21 @@ public class PropertySet extends DataType { return isReference() ? getRef()._mapper : _mapper; } + /** + * Convert the system properties to a hashtable. + * Use propertynames to get the list of properties (including + * default ones). + */ + private Hashtable getAllSystemProperties() { + Hashtable ret = new Hashtable(); + for (Enumeration e = System.getProperties().propertyNames(); + e.hasMoreElements();) { + String name = (String) e.nextElement(); + ret.put(name, System.getProperties().getProperty(name)); + } + return ret; + } + /** * this is the operation to get the existing or recalculated properties. * @return @@ -181,7 +196,7 @@ public class PropertySet extends DataType { Set names = null; Project prj = getProject(); Hashtable props = - prj == null ? System.getProperties() : prj.getProperties(); + prj == null ? getAllSystemProperties() : prj.getProperties(); if (getDynamic() || cachedNames == null) { names = new HashSet();