ant-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Jose Alberto Fernandez" <jalbe...@cellectivity.com>
Subject RE: cvs commit: ant/src/main/org/apache/tools/ant/types CommandlineJava.java PropertySet.java
Date Thu, 28 Oct 2004 10:59:05 GMT
> From: Peter Reilly [mailto:peterreilly@apache.org] 
> 
> Peter Reilly wrote:
> 
> > Stefan Bodewig wrote:
> >
> >> On Thu, 28 Oct 2004, Peter Reilly <peterreilly@apache.org> 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...
> >

The only thing we need to be sure is that is such exception occurs, then
ANT ends throwing a BuildException.
We are not suppose to fence for every bad API use of every user or every
IDE.

Jose Alberto

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


Mime
View raw message