classpath
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

patch for 0.12 (was: Re: java.lang.System changes)


From: Steven Augart
Subject: patch for 0.12 (was: Re: java.lang.System changes)
Date: Fri, 12 Nov 2004 11:18:01 -0500
User-agent: Mozilla/5.0 (X11; U; Linux i686; en-US; rv:1.7.3) Gecko/20040913

Jeroen Frijters wrote:
Steven Augart wrote:

I received a suggestion in private mail from David Holmes (who's been
generous with his time in discussing this with me) that we could
break up the initialization of java.lang.System into two
explicitly-invoked phases, and that a VM could optionally request that the initialization be broken up, based on a
configuration setting.
I've asked him for permission to forward the full text of his suggestion to the list.
I think that is the approach we will have to take.


Isn't it about time that we consider my suggestion to radically reduce
the whole initialization ordering mess by moving everything into
separate classes in the gnu.classpath.internal package?

I haven't read over your suggestion yet (I haven't been following the
classpath list as closely as I should have for the past month or so),
but it does sound like a good idea.  Obviously, with a release coming
out today, a temporary patch is probably a better idea, if it can be
squeezed in.

And, to that end, I have the following small patch that makes
the current Classpath CVS head work with Jikes RVM.  If someone
else approves it, I'll commit it.
--
Steven Augart

Jikes RVM, a free, open source, Virtual Machine:
http://oss.software.ibm.com/jikesrvm
This patch should be committed with the following ChangeLog entry:

2004-11-12  Steven Augart  <address@hidden>

        * 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. 
        
        
Index: configure.ac
===================================================================
RCS file: /cvsroot/classpath/classpath/configure.ac,v
retrieving revision 1.55
diff -I*.class -u -r1.55 configure.ac
--- configure.ac        26 Oct 2004 20:26:03 -0000      1.55
+++ configure.ac        12 Nov 2004 16:10:43 -0000
@@ -287,6 +287,23 @@
               [INIT_LOAD_LIBRARY="true"])
 AC_SUBST(INIT_LOAD_LIBRARY)
 
+
+dnl -----------------------------------------------------------
+dnl Should the VM explicitly run class initialization subfunctions for
+dnl java.lang.System?   (default is false -- the subfunctions will be run 
+dnl automatically by the class initializer)
+dnl -----------------------------------------------------------
+AC_ARG_ENABLE([java-lang-system-explicit-initialization],
+              
[AS_HELP_STRING(--enable-java-lang-system-explicit-initialization,will the VM 
explicitly invoke java.lang.System's static initialization methods 
[default=no])],
+              [case "${enableval}" in 
+                yes|true) JAVA_LANG_SYSTEM_EXPLICIT_INITIALIZATION="true" ;;
+                no|false) JAVA_LANG_SYSTEM_EXPLICIT_INITIALIZATION="false" ;;
+                *) AC_MSG_ERROR(bad value ${enableval} for 
--enable-java-lang-system-explicit-initialization) ;;
+              esac],
+              [JAVA_LANG_SYSTEM_EXPLICIT_INITIALIZATION="false"])
+AC_SUBST(JAVA_LANG_SYSTEM_EXPLICIT_INITIALIZATION)
+
+
 dnl -----------------------------------------------------------
 dnl avoiding automake complaints
 dnl -----------------------------------------------------------
Index: java/lang/System.java
===================================================================
RCS file: /cvsroot/classpath/classpath/java/lang/System.java,v
retrieving revision 1.43
diff -I*.class -u -r1.43 System.java
--- java/lang/System.java       8 Nov 2004 08:54:50 -0000       1.43
+++ java/lang/System.java       12 Nov 2004 16:10:43 -0000
@@ -64,8 +64,11 @@
    * 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 @@
    */
   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 @@
     // 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)
       {
Index: gnu/classpath/Configuration.java.in
===================================================================
RCS file: /cvsroot/classpath/classpath/gnu/classpath/Configuration.java.in,v
retrieving revision 1.12
diff -I*.class -u -r1.12 Configuration.java.in
--- gnu/classpath/Configuration.java.in 17 Nov 2003 18:56:51 -0000      1.12
+++ gnu/classpath/Configuration.java.in 12 Nov 2004 16:10:43 -0000
@@ -1,3 +1,4 @@
+/* -*-java-*- */
 /* gnu.classpath.Configuration
    Copyright (C) 1998, 2001, 2003 Free Software Foundation, Inc.
 
@@ -110,4 +111,16 @@
    * 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@;
 }

reply via email to

[Prev in Thread] Current Thread [Next in Thread]