Peter Reilly wrote:
Stefan Bodewig wrote:
On Thu, 28 Oct 2004, Peter Reilly <[EMAIL PROTECTED]> wrote:
Stefan Bodewig wrote:
What if the keys/values are not Strings?
In this case, the "properties" are from System.getProperties() and
not from Project.getProperties().... so they are strings.
Who is going to prevent System.getProperties().put(Object, Class)?
Nothing... However, it is breaking the usage of properties, for example: public class Test { public static void main(String[] args) { Integer i = new Integer(10); System.getProperties().put(i, "10"); System.getProperties().list(System.out); } }
Acutally: Integer i = new Integer(10); System.getProperties().put(i, "10"); Enumeration names = System.getProperties().propertyNames();
Also gives the java.lang.ClassCastException exception.
Since Properties.propertyNames() is the correct way to retieve the names
of the system properties, we cannot check if the user has messed up the contents
of the properties (without always iterating over the contents and removing invalid
keys and values and *then* calling propertyNames).
Peter
gets an exception: Caused by: java.lang.ClassCastException: java.lang.Integer at java.util.Properties.enumerate(Properties.java:869) at java.util.Properties.list(Properties.java:823) at Test.main(Unknown Source)
We could put a check in, but as it is not in the jdk for (is it 10 years??), it
may not be vital...
Peter
Stefan
--------------------------------------------------------------------- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
--------------------------------------------------------------------- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
--------------------------------------------------------------------- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]