/[classpath]/classpath/java/lang/System.java
ViewVC logotype

Diff of /classpath/java/lang/System.java

Parent Directory Parent Directory | Revision Log Revision Log | View Patch Patch

revision 1.38.2.6 by gnu_andrew, Sat Jan 15 17:01:53 2005 UTC revision 1.38.2.7 by gnu_andrew, Sun Jan 16 02:14:48 2005 UTC
# Line 62  public final class System Line 62  public final class System
62    // in vm/reference/java/lang/Runtime for implications of this fact.    // in vm/reference/java/lang/Runtime for implications of this fact.
63    
64    /**    /**
65       * The System Class Loader (a.k.a. Application Class Loader). The one
66       * returned by ClassLoader.getSystemClassLoader. It lives here to prevent
67       * a circular initialization dependency between System and ClassLoader.
68       *
69       * We can't make it a blank final, since initSystemClassLoader is a
70       * sub-function.
71       */
72      static ClassLoader systemClassLoader;
73    
74      /**
75       * Stores the current system properties. This can be modified by
76       * {@link #setProperties(Properties)}, but will never be null, because
77       * setProperties(null) sucks in the default properties.
78       */
79      static Properties properties;
80    
81      /**
82       * The standard InputStream. This is assigned at startup and starts its
83       * life perfectly valid. Although it is marked final, you can change it
84       * using {@link #setIn(InputStream)} through some hefty VM magic.
85       *
86       * <p>This corresponds to the C stdin and C++ cin variables, which
87       * typically input from the keyboard, but may be used to pipe input from
88       * other processes or files.  That should all be transparent to you,
89       * however.
90       */
91      public static final InputStream in;
92    
93      /**
94       * The standard output PrintStream.  This is assigned at startup and
95       * starts its life perfectly valid. Although it is marked final, you can
96       * change it using {@link #setOut(PrintStream)} through some hefty VM magic.
97       *
98       * <p>This corresponds to the C stdout and C++ cout variables, which
99       * typically output normal messages to the screen, but may be used to pipe
100       * output to other processes or files.  That should all be transparent to
101       * you, however.
102       */
103      public static final PrintStream out;
104    
105      /**
106       * The standard output PrintStream.  This is assigned at startup and
107       * starts its life perfectly valid. Although it is marked final, you can
108       * change it using {@link #setErr(PrintStream)} through some hefty VM magic.
109       *
110       * <p>This corresponds to the C stderr and C++ cerr variables, which
111       * typically output error messages to the screen, but may be used to pipe
112       * output to other processes or files.  That should all be transparent to
113       * you, however.
114       */
115      public static final PrintStream err;
116    
117      /**
118     * Add to the default properties. The field is stored in Runtime, because     * Add to the default properties. The field is stored in Runtime, because
119     * of the bootstrap sequence; but this adds several useful properties to     * of the bootstrap sequence; but this adds several useful properties to
120     * the defaults. Once the default is stabilized, it should not be modified;     * the defaults. Once the default is stabilized, it should not be modified;
# Line 70  public final class System Line 123  public final class System
123     */     */
124    static    static
125    {    {
126        if (! Configuration.JAVA_LANG_SYSTEM_EXPLICIT_INITIALIZATION) {
127          initLoadLibrary();
128          initProperties();
129        }
130        // We *have to* explicitly initialize the streams here, since they're a
131        // blank final field.
132        in = VMSystem.makeStandardInputStream();
133        out = VMSystem.makeStandardOutputStream();
134        err = VMSystem.makeStandardErrorStream();
135        
136        if (! Configuration.JAVA_LANG_SYSTEM_EXPLICIT_INITIALIZATION) {
137          initSystemClassLoader();
138          initSecurityManager();    // Includes getting the class loader.
139        }
140      }
141    
142      static void initLoadLibrary () {
143      // Note that this loadLibrary() takes precedence over the one in Object,      // Note that this loadLibrary() takes precedence over the one in Object,
144      // since Object.<clinit> is waiting for System.<clinit> to complete      // since Object.<clinit> is waiting for System.<clinit> to complete
145      // first; but loading a library twice is harmless.      // first; but loading a library twice is harmless.
146      if (Configuration.INIT_LOAD_LIBRARY)      if (Configuration.INIT_LOAD_LIBRARY)
147        loadLibrary("javalang");        loadLibrary("javalang");
148    
149      }
150    
151      static void initProperties() {
152      Properties defaultProperties = Runtime.defaultProperties;      Properties defaultProperties = Runtime.defaultProperties;
153      defaultProperties.put("gnu.classpath.home",      defaultProperties.put("gnu.classpath.home",
154                      Configuration.CLASSPATH_HOME);                      Configuration.CLASSPATH_HOME);
# Line 233  public final class System Line 306  public final class System
306      if (defaultProperties.get("java.io.tmpdir") == null)      if (defaultProperties.get("java.io.tmpdir") == null)
307        defaultProperties.put("java.io.tmpdir",        defaultProperties.put("java.io.tmpdir",
308                              defaultProperties.get("java.tmpdir"));                              defaultProperties.get("java.tmpdir"));
   }  
309    
310    /**      // Note that we use clone here and not new.  Some programs assume
311     * Stores the current system properties. This can be modified by      // that the system properties do not have a parent.
312     * {@link #setProperties(Properties)}, but will never be null, because      properties = (Properties) Runtime.defaultProperties.clone();
313     * 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.  
   static Properties properties  
     = (Properties) Runtime.defaultProperties.clone();  
   
   /**  
    * The standard InputStream. This is assigned at startup and starts its  
    * life perfectly valid. Although it is marked final, you can change it  
    * using {@link #setIn(InputStream)} through some hefty VM magic.  
    *  
    * <p>This corresponds to the C stdin and C++ cin variables, which  
    * typically input from the keyboard, but may be used to pipe input from  
    * other processes or files.  That should all be transparent to you,  
    * however.  
    */  
   public static final InputStream in = VMSystem.makeStandardInputStream();  
314    
315    /**    static void initSystemClassLoader() {
316     * The standard output PrintStream.  This is assigned at startup and      systemClassLoader = VMClassLoader.getSystemClassLoader();
317     * starts its life perfectly valid. Although it is marked final, you can    }
    * change it using {@link #setOut(PrintStream)} through some hefty VM magic.  
    *  
    * <p>This corresponds to the C stdout and C++ cout variables, which  
    * typically output normal messages to the screen, but may be used to pipe  
    * output to other processes or files.  That should all be transparent to  
    * you, however.  
    */  
   public static final PrintStream out = VMSystem.makeStandardOutputStream();  
318    
319    /**    static void initSecurityManager () {
320     * The standard output PrintStream.  This is assigned at startup and      String secman = properties.getProperty("java.security.manager");
321     * starts its life perfectly valid. Although it is marked final, you can      if (secman != null)
322     * change it using {@link #setErr(PrintStream)} through some hefty VM magic.        {
323     *          if (secman.equals("") || secman.equals("default"))
324     * <p>This corresponds to the C stderr and C++ cerr variables, which            {
325     * typically output error messages to the screen, but may be used to pipe              Runtime.securityManager = new java.lang.SecurityManager();
326     * output to other processes or files.  That should all be transparent to            }
327     * you, however.          else
328     */            {
329    public static final PrintStream err = VMSystem.makeStandardErrorStream();              try
330                  {
331                    Class cl = Class.forName(secman, false, systemClassLoader);
332                    Runtime.securityManager = (SecurityManager)cl.newInstance();
333                  }
334                catch (Exception x)
335                  {
336                    throw (InternalError)
337                        new InternalError("Unable to create SecurityManager")
338                            .initCause(x);
339                  }
340              }
341          }
342      }
343    
344    /**    /**
345     * This class is uninstantiable.     * This class is uninstantiable.

Legend:
Removed from v.1.38.2.6  
changed lines
  Added in v.1.38.2.7

savannah-hackers-public@gnu.org
ViewVC Help
Powered by ViewVC 1.1.26