summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorSteven Augart <augart@watson.ibm.com>2004-11-12 17:00:31 +0000
committerSteven Augart <augart@watson.ibm.com>2004-11-12 17:00:31 +0000
commit749febb3a3f5cfe352b62577c01d1cf8573630a8 (patch)
treed8fe220553689f128a94a2c99226f30afbb955ad
parent59079447533574fce0d418f835a252ae0fb4fd0e (diff)
downloadclasspath-749febb3a3f5cfe352b62577c01d1cf8573630a8.tar.gz
2004-11-12 Steven Augart <augart@watson.ibm.com>
* gnu/classpath/Configuration.java.in: Added JAVA_LANG_SYSTEM_EXPLICIT_INITIALIZATION. * configure.ac: Added --enable-java-lang-system-explicit-initialization. * java/lang/System.java: Added support for JAVA_LANG_SYSTEM_EXPLICIT_INITIALIZATION.
-rw-r--r--ChangeLog10
-rw-r--r--gnu/classpath/Configuration.java.in13
-rw-r--r--java/lang/System.java33
3 files changed, 51 insertions, 5 deletions
diff --git a/ChangeLog b/ChangeLog
index 15308aef2..b554798fc 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,13 @@
+2004-11-12 Steven Augart <augart@watson.ibm.com>
+
+ * gnu/classpath/Configuration.java.in: Added
+ JAVA_LANG_SYSTEM_EXPLICIT_INITIALIZATION.
+ * configure.ac: Added
+ --enable-java-lang-system-explicit-initialization.
+ * java/lang/System.java: Added support for
+ JAVA_LANG_SYSTEM_EXPLICIT_INITIALIZATION.
+
+
2004-11-12 Sven de Marothy <sven@physto.se>
* java/awt/Polygon.java (contains): Reimplemented.
diff --git a/gnu/classpath/Configuration.java.in b/gnu/classpath/Configuration.java.in
index f79dcde71..9bbff6532 100644
--- a/gnu/classpath/Configuration.java.in
+++ b/gnu/classpath/Configuration.java.in
@@ -1,3 +1,4 @@
+/* -*-java-*- */
/* gnu.classpath.Configuration
Copyright (C) 1998, 2001, 2003 Free Software Foundation, Inc.
@@ -110,4 +111,16 @@ public interface Configuration
* Name of default AWT peer library.
*/
String default_awt_peer_toolkit = "gnu.java.awt.peer.gtk.GtkToolkit";
+
+ /**
+ * Whether to automatically run the init* methods in java.lang.System
+ * (the default) at class initialization time or whether to have the VM
+ * explicitly invoke them.
+ *
+ * The default is false, meaning the VM does not explicitly run the
+ * initializers.
+ *
+ */
+ boolean JAVA_LANG_SYSTEM_EXPLICIT_INITIALIZATION =
+ @JAVA_LANG_SYSTEM_EXPLICIT_INITIALIZATION@;
}
diff --git a/java/lang/System.java b/java/lang/System.java
index 4e264da1f..46fec962d 100644
--- a/java/lang/System.java
+++ b/java/lang/System.java
@@ -64,8 +64,11 @@ public final class System
* The System Class Loader (a.k.a. Application Class Loader). The one
* returned by ClassLoader.getSystemClassLoader. It lives here to prevent
* a circular initialization dependency between System and ClassLoader.
+ *
+ * We can't make it a blank final, since initSystemClassLoader is a
+ * sub-function.
*/
- static final ClassLoader systemClassLoader;
+ static ClassLoader systemClassLoader;
/**
* Stores the current system properties. This can be modified by
@@ -119,12 +122,32 @@ public final class System
*/
static
{
+ if (! Configuration.JAVA_LANG_SYSTEM_EXPLICIT_INITIALIZATION) {
+ initLoadLibrary();
+ initProperties();
+ }
+ // We *have to* explicitly initialize the streams here, since they're a
+ // blank final field.
+ in = VMSystem.makeStandardInputStream();
+ out = VMSystem.makeStandardOutputStream();
+ err = VMSystem.makeStandardErrorStream();
+
+ if (! Configuration.JAVA_LANG_SYSTEM_EXPLICIT_INITIALIZATION) {
+ initSystemClassLoader();
+ initSecurityManager(); // Includes getting the class loader.
+ }
+ }
+
+ static void initLoadLibrary () {
// Note that this loadLibrary() takes precedence over the one in Object,
// since Object.<clinit> is waiting for System.<clinit> to complete
// first; but loading a library twice is harmless.
if (Configuration.INIT_LOAD_LIBRARY)
loadLibrary("javalang");
+ }
+
+ static void initProperties() {
Properties defaultProperties = Runtime.defaultProperties;
defaultProperties.put("gnu.classpath.home",
Configuration.CLASSPATH_HOME);
@@ -286,13 +309,13 @@ public final class System
// 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();
+ }
- in = VMSystem.makeStandardInputStream();
- out = VMSystem.makeStandardOutputStream();
- err = VMSystem.makeStandardErrorStream();
-
+ static void initSystemClassLoader() {
systemClassLoader = VMClassLoader.getSystemClassLoader();
+ }
+ static void initSecurityManager () {
String secman = properties.getProperty("java.security.manager");
if (secman != null)
{