Properties.list( ) Regression in 3.3

Andrew Haley aph@redhat.com
Thu Feb 13 09:22:00 GMT 2003


Ranjit Mathew writes:
 > Hi,
 > 
 >     The following simple program no longer prints the expected
 > output with GCJ 3.3, though it works with both GCJ 3.2 as well as
 > Sun's JDK 1.4.1.01:
 > ----------------------------- 8< -------------------------------
 > public class HelloWorld {
 > 
 >     public static void main( String[] args) {
 >         System.getProperties( ).list( System.out);
 >     }
 > }
 > ----------------------------- 8< -------------------------------
 > 
 > I could trace it to the fact that in GCJ 3.3, System.getProperties( )
 > is returning in (essentially):
 > 
 >     new Properties( Runtime.defaultProperties);
 > 
 > which creates a Properties object with the given default values.
 > Now Properties.list( ) refuses to print out the default values 
 > of properties the way Properties.store( ) refuses to write out 
 > default values of properties.
 > 
 > However, while the latter is specified by Sun's JDK docs, the former
 > is not. To remedy this problem we can either:
 > 
 > a. Use Runtime.defaultProperties.clone( ) to create the Properties
 >    object returned by System.getProperties( ).
 > 
 > b. Remove the restriction in Properties.list( ) about printing out
 >    default values of properties.
 > 
 > Which of the alternatives is preferable? Should I post a patch for
 > the same?

B, I would have thought.  The specs don't seem to say what the format
should be, so perhaps we can look at the output of some othe JRE and
do the same thing.

Andrew.



More information about the Java mailing list