Patch: FYI: clone System properties
Tom Tromey
tromey@redhat.com
Fri Feb 14 17:42:00 GMT 2003
I'm checking this in to 3.3, 3.4, and Classpath.
Some programs (e.g., ant) expect the system properties not to have a
parent. While this is a bug in those programs, I've seen 3 reports of
this problem this week alone. It seems convenient for us to be
compatible here, and it is easy.
Tested on x86 RHL 7.3.
Tom
Index: ChangeLog
from Tom Tromey <tromey@redhat.com>
* java/lang/System.java (properties): Use Properties.clone.
(setProperties): Likewise.
Index: java/lang/System.java
===================================================================
RCS file: /cvs/gcc/gcc/libjava/java/lang/System.java,v
retrieving revision 1.10.20.1
diff -u -r1.10.20.1 System.java
--- java/lang/System.java 31 Dec 2002 22:49:36 -0000 1.10.20.1
+++ java/lang/System.java 14 Feb 2003 17:40:38 -0000
@@ -1,5 +1,5 @@
/* System.java -- useful methods to interface with the system
- Copyright (C) 1998, 1999, 2000, 2001, 2002 Free Software Foundation, Inc.
+ Copyright (C) 1998, 1999, 2000, 2001, 2002, 2003 Free Software Foundation, Inc.
This file is part of GNU Classpath.
@@ -104,8 +104,10 @@
* {@link #setProperties(Properties)}, but will never be null, because
* setProperties(null) sucks in the default properties.
*/
+ // Note that we use clone here and not new. Some programs assume
+ // that the system properties do not have a parent.
private static Properties properties
- = new Properties(Runtime.defaultProperties);
+ = (Properties) Runtime.defaultProperties.clone();
/**
* The standard InputStream. This is assigned at startup and starts its
@@ -369,7 +371,11 @@
if (sm != null)
sm.checkPropertiesAccess();
if (properties == null)
- properties = new Properties(Runtime.defaultProperties);
+ {
+ // Note that we use clone here and not new. Some programs
+ // assume that the system properties do not have a parent.
+ properties = (Properties) Runtime.defaultProperties.clone();
+ }
System.properties = properties;
}
More information about the Java-patches
mailing list