ant-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From bugzi...@apache.org
Subject [Bug 904] Changed - Reading System Properties may return Objects
Date Mon, 12 Mar 2001 13:58:46 GMT
http://nagoya.apache.org/bugzilla/show_bug.cgi?id=904

*** shadow/904	Mon Mar 12 05:32:47 2001
--- shadow/904.tmp.28987	Mon Mar 12 05:58:46 2001
***************
*** 52,55 ****
  block.  getProperty will only return String-values, and will also search any 
  defaults that the Properties block has, which is another important Properties 
  feature.  (Note: I have not looked at the surrounding code much, so I don't 
! actually know if you want this - just wanted to point it out)
--- 52,96 ----
  block.  getProperty will only return String-values, and will also search any 
  defaults that the Properties block has, which is another important Properties 
  feature.  (Note: I have not looked at the surrounding code much, so I don't 
! actually know if you want this - just wanted to point it out)
! 
! ------- Additional Comments From peter.holzwarth@io-software.com  2001-03-12 05:58 -------
! (I used reply to send my answer, but that didn't show up anywhere, so I'm trying 
! out the form now...) 
! 
! 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);
! ----------------------------------

---------------------------------------------------------------------
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