ant-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Peter Holzwarth <Peter.Holzwa...@io-software.com>
Subject Re: [Bug 904] Changed - Reading System Properties may return Objects
Date Mon, 12 Mar 2001 12:56:42 GMT
Hi Stefan,

we're using ant from within our ArcStyler IDE in-process. Inside our IDE, we're using
the system properties to transport context information between classes that run within
different class loaders. As an example, we're writing things like

----------------------------------
System.getProperties().put("myKey", new Integer(3));
----------------------------------

This appears to be completely legal regarding the JDK. The getProperty() method
implemented in the JDK simply ignores non-string values:
----------------------------------
public String getProperty(String key) {
 Object oval = super.get(key);
 String sval = (oval instanceof String) ? (String)oval : null;
 return ((sval == null) && (defaults != null)) ? defaults.getProperty(key) : sval;
}
----------------------------------

This might be feasible for ant, too. Or, ant may use a toString() on the objects. Both
make sense in some situations. However, the current behaviour of ant is that it throws
a class cast exception, which shouldn't be.

If you decide to interpret the semantics of the Properties class in a strict way, I
would suggest writing

----------------------------------
String value = systemP.getProperty(name);
----------------------------------

instead of

----------------------------------
String value = (String) systemP.get(name);
----------------------------------


-- best regards,
Peter.


                                    Interactive Objects Software GmbH
---- < iO > ----------------------------------------------------------
    Interactive Objects Software GmbH (iO)  phone (+49)-761-400 73-0
    Baslerstr. 63, 79100 Freiburg, Germany  fax   (+49)-761-400 73-73
    mailto:Peter.Holzwarth@io-software.com  http://www.io-software.com
______________________________________________________________________
ArcStyler - the IT-Architectural IDE for J2EE/EJB
  -> free trial-version at http://www.ArcStyler.com
  -> recent Awards at http://www.ArcStyler.com/news


bugzilla@apache.org wrote:

> http://nagoya.apache.org/bugzilla/show_bug.cgi?id=904
>
> *** shadow/904  Thu Mar  8 09:38:29 2001
> --- shadow/904.tmp.27780        Mon Mar 12 03:48:04 2001
> ***************
> *** 5,11 ****
>   |       Status: NEW                         Version: 1.2                     |
>   |   Resolution:                            Platform: All                     |
>   |     Severity: Normal                   OS/Version: All                     |
> ! |     Priority:                           Component: Core                    |
>   +----------------------------------------------------------------------------+
>   |  Assigned To: ant-dev@jakarta.apache.org                                   |
>   |  Reported By: peter.holzwarth@io-software.com                              |
> --- 5,11 ----
>   |       Status: NEW                         Version: 1.2                     |
>   |   Resolution:                            Platform: All                     |
>   |     Severity: Normal                   OS/Version: All                     |
> ! |     Priority: High                      Component: Core                    |
>   +----------------------------------------------------------------------------+
>   |  Assigned To: ant-dev@jakarta.apache.org                                   |
>   |  Reported By: peter.holzwarth@io-software.com                              |
> ***************
> *** 31,34 ****
>   207c207
>   <             String value = (String) systemP.get(name);
>   ---
> ! >             String value = systemP.get(name).toString();
> --- 31,41 ----
>   207c207
>   <             String value = (String) systemP.get(name);
>   ---
> ! >             String value = systemP.get(name).toString();
> !
> ! ------- Additional Comments From bodewig@apache.org  2001-03-12 03:48 -------
> ! Peter, could you please explain this a little more?
> !
> ! System.getProperties returns a Properties instance, which by definition contains
> ! keys and values of type String - nothing else. How would you insert Objects into
> ! the system properties?


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


Mime
View raw message