/[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.13 by mark, Tue Jan 22 22:27:00 2002 UTC revision 1.14 by ericb, Wed Feb 27 06:02:11 2002 UTC
# Line 1  Line 1 
1  /* java.lang.System  /* System.java -- useful methods to interface with the system
2     Copyright (C) 1998, 1999, 2000, 2001 Free Software Foundation, Inc.     Copyright (C) 1998, 1999, 2000, 2001, 2002 Free Software Foundation, Inc.
3    
4  This file is part of GNU Classpath.  This file is part of GNU Classpath.
5    
# Line 7  GNU Classpath is free software; you can Line 7  GNU Classpath is free software; you can
7  it under the terms of the GNU General Public License as published by  it under the terms of the GNU General Public License as published by
8  the Free Software Foundation; either version 2, or (at your option)  the Free Software Foundation; either version 2, or (at your option)
9  any later version.  any later version.
10    
11  GNU Classpath is distributed in the hope that it will be useful, but  GNU Classpath is distributed in the hope that it will be useful, but
12  WITHOUT ANY WARRANTY; without even the implied warranty of  WITHOUT ANY WARRANTY; without even the implied warranty of
13  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
# Line 43  import java.util.*; Line 43  import java.util.*;
43  import gnu.classpath.Configuration;  import gnu.classpath.Configuration;
44    
45  /**  /**
46   * System represents system-wide resources; things that   * System represents system-wide resources; things that represent the
47   * represent the general environment.  As such, all   * general environment.  As such, all methods are static.
  * methods are static.  
48   *   *
49   * @author John Keiser   * @author John Keiser
50   * @version 1.1.0, Aug 8 1998   * @author Eric Blake <ebb9@email.byu.edu>
51   * @since JDK1.0   * @since 1.0
52     * @status still missing 1.4 functionality
53   */   */
   
54  public class System  public class System
55  {  {
56      /**
57       * Load native methods.
58       */
59    static    static
60    {    {
61      if (Configuration.INIT_LOAD_LIBRARY)      if (Configuration.INIT_LOAD_LIBRARY)
62        {        {
63          System.loadLibrary ("javalang");          System.loadLibrary("javalang");
64        }        }
65    }    }
66    
67    /* This class is uninstantiable. */    /**
68    private System ()     * This class is uninstantiable.
69       */
70      private System()
71    {    {
72    }    }
73    
74      /**
75       * Stores the system properties.
76       */
77    private static Properties properties;    private static Properties properties;
78    
79          /** The standard InputStream.  This is assigned at    /**
80           ** startup and starts its life perfectly valid.<P>     * The standard InputStream. This is assigned at startup and starts its
81           ** This corresponds to the C stdin and C++ cin     * life perfectly valid. Although it is marked final, you can change it
82           ** variables, which typically input from the keyboard,     * using {@link #setIn(InputStream)} through some hefty VM magic.
83           ** but may be used to pipe input from other processes     *
84           ** or files.  That should all be transparent to you,     * <p>This corresponds to the C stdin and C++ cin variables, which
85           ** however.     * typically input from the keyboard, but may be used to pipe input from
86           **/     * other processes or files.  That should all be transparent to you,
87       * however.
88       */
89    public static final InputStream in;    public static final InputStream in;
90    
91          /** The standard output PrintStream.  This is assigned at    /**
92           ** startup and starts its life perfectly valid.<P>     * The standard output PrintStream.  This is assigned at startup and
93           ** This corresponds to the C stderr and C++ cerr     * starts its life perfectly valid. Although it is marked final, you can
94           ** variables, which typically output to the screen,     * change it using {@link #setOut(PrintStream)} through some hefty VM magic.
95           ** but may be used to pipe output to other processes     *
96           ** or files.  That should all be transparent to you,     * <p>This corresponds to the C stdout and C++ cout variables, which
97           ** however.     * typically output normal messages to the screen, but may be used to pipe
98           **/     * output to other processes or files.  That should all be transparent to
99       * you, however.
100       */
101    public static final PrintStream out;    public static final PrintStream out;
102    
103          /** The standard error PrintStream.  This is assigned at    /**
104           ** startup and starts its life perfectly valid.<P>     * The standard output PrintStream.  This is assigned at startup and
105           ** This corresponds to the C stdout and C++ cout     * starts its life perfectly valid. Although it is marked final, you can
106           ** variables, which typically output to the screen,     * change it using {@link #setOut(PrintStream)} through some hefty VM magic.
107           ** but may be used to pipe output to other processes     *
108           ** or files.  That should all be transparent to you,     * <p>This corresponds to the C stderr and C++ cerr variables, which
109           ** however.     * typically output error messages to the screen, but may be used to pipe
110           **/     * output to other processes or files.  That should all be transparent to
111       * you, however.
112       */
113    public static final PrintStream err;    public static final PrintStream err;
114    
115      /**
116       * Initialize the properties and I/O streams.
117       */
118    static    static
119    {    {
120      properties = new Properties ();      properties = new Properties();
121      VMSystem.insertSystemProperties (properties);      VMSystem.insertSystemProperties(properties);
122      insertGNUProperties ();      insertGNUProperties();
123      in = new FileInputStream (FileDescriptor.in);      in = new FileInputStream(FileDescriptor.in);
124      out = new PrintStream (new FileOutputStream (FileDescriptor.out));      out = new PrintStream(new FileOutputStream(FileDescriptor.out));
125      err = new PrintStream (new FileOutputStream (FileDescriptor.err));      err = new PrintStream(new FileOutputStream(FileDescriptor.err));
126    }    }
127    
128          /** Set in to a new InputStream.    /**
129           ** @param in the new InputStream.     * Set {@link #in} to a new InputStream. This uses some VM magic to change
130           ***/     * a "final" variable, so naturally there is a security check,
131    public static native void setIn (InputStream in);     * <code>RuntimePermission("setIO")</code>.
132       *
133          /** Set out to a new PrintStream.     * @param in the new InputStream
134           ** @param out the new PrintStream.     * @throws SecurityException if permission is denied
135           ***/     * @since 1.1
136    public static native void setOut (PrintStream out);     * @XXX Perform security check (which means setIn should probably be in
137       *      Java, and add setIn0 as native).
138          /** Set err to a new PrintStream.     */
139           ** @param err the new PrintStream.    public static native void setIn(InputStream in);
140           ***/  
141    public static native void setErr (PrintStream err);    /**
142       * Set {@link #out} to a new PrintStream. This uses some VM magic to change
143          /** Get the current SecurityManager.     * a "final" variable, so naturally there is a security check,
144           ** If the SecurityManager has not been set yet, then this     * <code>RuntimePermission("setIO")</code>.
145           ** method returns null.     *
146           ** @return the current SecurityManager, or null.     * @param out the new PrintStream
147           **/     * @throws SecurityException if permission is denied
148    public static SecurityManager getSecurityManager ()     * @since 1.1
149    {     * @XXX Perform security check (which means setOut should probably be in
150      return Runtime.getSecurityManager ();     *      Java, and add setOut0 as native).
151    }     */
152      public static native void setOut(PrintStream out);
153          /** Set the current SecurityManager.  
154           ** This may only be done once.  If you try to re-set the    /**
155           ** current SecurityManager, then you will get a     * Set {@link #err} to a new PrintStream. This uses some VM magic to change
156           ** SecurityException.  If you use null and there is no     * a "final" variable, so naturally there is a security check,
157           ** SecurityManager set, then the state will not     * <code>RuntimePermission("setIO")</code>.
158           ** change.<P>     *
159           ** <STRONG>Spec Note:</STRONG> Don't ask me, I didn't     * @param err the new PrintStream
160           ** write it.  It looks pretty vulnerable; whoever gets to     * @throws SecurityException if permission is denied
161           ** the gate first gets to set the policy.     * @since 1.1
162           **     * @XXX Perform security check (which means setErr should probably be in
163           ** @param securityManager the new SecurityManager.     *      Java, and add setErr0 as native).
164           ** @exception SecurityException if the SecurityManger is     */
165           **            already set.    public static native void setErr(PrintStream err);
166           **/  
167    public static void setSecurityManager (SecurityManager securityManager)    /**
168    {     * Set the current SecurityManager. If a security manager already exists,
169      Runtime.setSecurityManager (securityManager);     * then <code>RuntimePermission("setSecurityManager")</code> is checked
170    }     * first. Since this permission is denied by the default security manager,
171       * setting the security manager is often an irreversible action.
172          /** Get the current time, measured in the number of     *
173           ** milliseconds from the beginning of Jan. 1, 1970.     * <STRONG>Spec Note:</STRONG> Don't ask me, I didn't write it.  It looks
174           ** This is gathered from the system clock, with any     * pretty vulnerable; whoever gets to the gate first gets to set the policy.
175           ** attendant incorrectness (it may be timezone     * There is probably some way to set the original security manager as a
176           ** dependent).     * command line argument to the VM, but I don't know it.
177           ** @return the current time.     *
178           **/     * @param securityManager the new SecurityManager
179    public static native long currentTimeMillis ();     * @throws SecurityException if permission is denied
180       */
181          /** Copy one array onto another from    public static void setSecurityManager(SecurityManager securityManager)
182           ** <CODE>src[srcStart] ... src[srcStart+len]</CODE> to    {
183           ** <CODE>dest[destStart] ... dest[destStart+len]</CODE>      // Implementation note: this is done in Runtime because of bootstrap
184           ** @param src the array to copy elements from      // initialization issues.
185           ** @param srcStart the starting position to copy elements      Runtime.setSecurityManager(securityManager);
186           **        from in the src array    }
187           ** @param dest the array to copy elements to  
188           ** @param destStart the starting position to copy    /**
189           **        elements from in the src array     * Get the current SecurityManager. If the SecurityManager has not been
190           ** @param len the number of elements to copy     * set yet, then this method returns null.
191           ** @exception ArrayStoreException if src or dest is not     *
192           **            an array, or if one is a primitive type     * @return the current SecurityManager, or null
193           **            and the other is a reference type or a     */
194           **            different primitive type.  The array will    public static SecurityManager getSecurityManager()
195           **            not be modified if any of these is the    {
196           **            case.  If there is an element in src that      // Implementation note: this is done in Runtime because of bootstrap
197           **            is not assignable to dest's type, this will      // initialization issues.
198           **            be thrown and all elements up to but not      return Runtime.getSecurityManager();
199           **            including that element will have been    }
200           **            modified.  
201           ** @exception ArrayIndexOutOfBoundsException if len is    /**
202           **            negative, or if the start or end copy     * Get the current time, measured in the number of milliseconds from the
203           **            position in either array is out of bounds.     * beginning of Jan. 1, 1970. This is gathered from the system clock, with
204           **            The array will not be modified if this     * any attendant incorrectness (it may be timezone dependent).
205           **            exception is thrown.     *
206           **/     * @return the current time
207    public static void arraycopy (Object src, int srcStart, Object dest,     * @see java.util.Date
208                                  int destStart, int len)     */
209    {    public static native long currentTimeMillis();
210      VMSystem.arraycopy (src, srcStart, dest, destStart, len);  
211    }    /**
212       * Copy one array onto another from <code>src[srcStart]</code> ...
213          /** Get a hash code computed by the VM for the Object.     * <code>src[srcStart+len-1]</code> to <code>dest[destStart]</code> ...
214           ** This hash code will be the same as Object's hashCode()     * <code>dest[destStart+len-1]</code>. First, the arguments are validated:
215           ** method.  It is usually some convolution of the pointer     * neither array may be null, they must be of compatible types, and the
216           ** to the Object internal to the VM.  It follows standard     * start and length must fit within both arrays. Then the copying starts,
217           ** hash code rules, in that it will remain the same for a     * and proceeds through increasing slots.  If src and dest are the same
218           ** given Object for the lifetime of that Object.     * array, this will appear to copy the data to a temporary location first.
219           ** @param o the Object to get the hash code for     * An ArrayStoreException in the middle of copying will leave earlier
220           ** @return the VM-dependent hash code for this Object     * elements copied, but later elements unchanged.
221           **/     *
222    public static int identityHashCode (Object o)     * @param src the array to copy elements from
223    {     * @param srcStart the starting position in src
224      return VMSystem.identityHashCode (o);     * @param dest the array to copy elements to
225    }     * @param destStart the starting position in dest
226       * @param len the number of elements to copy
227          /** Get all the system properties at once.     * @throws NullPointerException if src or dest is null
228           ** @XXX list the standard system properties     * @throws ArrayStoreException if src or dest is not an array, if they are
229           ** @return the system properties     *         not compatible array types, or if an incompatible runtime type
230           ** @exception SecurityException if thrown by     *         is stored in dest
231           **            getSecurityManager().checkPropertiesAccess()     * @throws IndexOutOfBoundsException if len is negative, or if the start or
232           **/     *         end copy position in either array is out of bounds
233    public static Properties getProperties ()     */
234    {    public static void arraycopy(Object src, int srcStart,
235      try                                 Object dest, int destStart, int len)
236      {    {
237        getSecurityManager ().checkPropertiesAccess ();      VMSystem.arraycopy(src, srcStart, dest, destStart, len);
238      }    }
239      catch (NullPointerException e)  
240      {    /**
241      }     * Get a hash code computed by the VM for the Object. This hash code will
242      return properties;     * be the same as Object's hashCode() method.  It is usually some
243    }     * convolution of the pointer to the Object internal to the VM.  It
244       * follows standard hash code rules, in that it will remain the same for a
245          /** Set all the system properties at once.     * given Object for the lifetime of that Object.
246           ** @param properties the new set of system properties.     *
247           ** @exception SecurityException if thrown by     * @param o the Object to get the hash code for
248           **            getSecurityManager().checkPropertiesAccess()     * @return the VM-dependent hash code for this Object
249           **/     * @since 1.1
250    public static void setProperties (Properties properties)     */
251    {    public static int identityHashCode(Object o)
252      try    {
253      {      return VMSystem.identityHashCode(o);
254        getSecurityManager ().checkPropertiesAccess ();    }
255      }  
256      catch (NullPointerException e)    /**
257      {     * Get all the system properties at once. A security check may be performed,
258      }     * <code>checkPropertiesAccess</code>. Note that a security manager may
259      System.properties = properties;     * allow getting a single property, but not the entire group.
260    }     *
261       * <p>The default properties include:
262       * <dl>
263          /** Get a single system property by name.     * <dt>java.version         <dd>Java version number
264           ** @param name the name of the system property to get     * <dt>java.vendor          <dd>Java vendor specific string
265           ** @return the property, or null if not found.     * <dt>java.vendor.url      <dd>Java vendor URL
266           ** @exception SecurityException if thrown by     * <dt>java.home            <dd>Java installation directory
267           **            getSecurityManager().checkPropertyAccess(name)     * <dt>java.vm.specification.version <dd>VM Spec version
268           **/     * <dt>java.vm.specification.vendor  <dd>VM Spec vendor
269    public static String getProperty (String name)     * <dt>java.vm.specification.name    <dd>VM Spec name
270    {     * <dt>java.vm.version      <dd>VM implementation version
271      SecurityManager sm = getSecurityManager ();     * <dt>java.vm.vendor       <dd>VM implementation vendor
272      try     * <dt>java.vm.name         <dd>VM implementation name
273      {     * <dt>java.specification.version    <dd>Java Runtime Environment version
274        sm.checkPropertyAccess (name);     * <dt>java.specification.vendor     <dd>Java Runtime Environment vendor
275      }     * <dt>java.specification.name       <dd>Java Runtime Environment name
276      catch (NullPointerException e)     * <dt>java.class.version   <dd>Java class version number
277      {     * <dt>java.class.path      <dd>Java classpath
278      }     * <dt>java.library.path    <dd>Path for finding Java libraries
279      return properties.getProperty (name);     * <dt>java.io.tmpdir       <dd>Default temp file path
280    }     * <dt>java.compiler        <dd>Name of JIT to use
281       * <dt>java.ext.dirs        <dd>Java extension path
282          /** Set a single system property by name.     * <dt>os.name              <dd>Operating System Name
283           ** @param name the name of the system property to set     * <dt>os.arch              <dd>Operating System Architecture
284           ** @param value the new value of the system property     * <dt>os.version           <dd>Operating System Version
285           ** @return the old property value, or null if not yet set     * <dt>file.separator       <dd>File separator ("/" on Unix)
286           ** @exception SecurityException if a SecurityManager is set     * <dt>path.separator       <dd>Path separator (":" on Unix)
287       **            and the caller doesn't have     * <dt>line.separator       <dd>Line separator ("\n" on Unix)
288           **            <code>PropertyPermission(name, "write")</code>     * <dt>user.name            <dd>User account name
289           **     * <dt>user.home            <dd>User home directory
290           ** @since 1.2     * <dt>user.dir             <dd>User's current working directory
291           **/     * </dl>
292    public static String setProperty (String name, String value)     *
293       * @return the system properties, will never be null
294       * @throws SecurityException if permission is denied
295       */
296      public static Properties getProperties()
297    {    {
298      SecurityManager sm = getSecurityManager ();      SecurityManager sm = Runtime.getSecurityManager();
299      if (sm != null)      if (sm != null)
300        sm.checkPermission (new PropertyPermission (name, "write"));        sm.checkPropertiesAccess();
301        //XXX Make sure this is not null, and be thread-safe
302      return (String) properties.setProperty (name, value);      return properties;
   }  
   
         /** Get a single property by name, with a possible default  
          ** value returned if not found.  
          ** @param name the name of the system property to set  
          ** @param def the default value to use if the  
          **        property does not exist.  
          ** @return the property, or default if not found.  
          ** @exception SecurityException if thrown by  
          **            getSecurityManager().checkPropertyAccess(name)  
          **/  
   public static String getProperty (String name, String def)  
   {  
     try  
     {  
       getSecurityManager ().checkPropertyAccess (name);  
     }  
     catch (NullPointerException e)  
     {  
     }  
     return properties.getProperty (name, def);  
   }  
   
         /** Get a single property by name.  Calls getProperty(name).  
          ** @deprecated use getProperty(name).  
          ** @see #getProperty(java.lang.String)  
          **/  
   public static String getenv (String name)  
   {  
     return getProperty (name);  
   }  
   
         /** Helper method to exit the Java runtime using  
          ** <CODE>Runtime.getRuntime().exit()</CODE>.  
          ** @see java.lang.Runtime#exit(int)  
          **/  
   public static void exit (int status)  
   {  
     Runtime.getRuntime ().exit (status);  
   }  
   
         /** Helper method to run the garbage collector using  
          ** <CODE>Runtime.getRuntime().gc()</CODE>.  
          ** @see java.lang.Runtime#gc()  
          **/  
   public static void gc ()  
   {  
     Runtime.getRuntime ().gc ();  
303    }    }
304    
305          /** Helper method to run finalization using    /**
306           ** <CODE>Runtime.getRuntime().runFinalization()</CODE>.     * Set all the system properties at once. A security check may be performed,
307           ** @see java.lang.Runtime#runFinalization()     * <code>checkPropertiesAccess</code>. Note that a security manager may
308           **/     * allow setting a single property, but not the entire group. An argument
309    public static void runFinalization ()     * of null resets the properties to the startup default.
310       *
311       * @param properties the new set of system properties
312       * @throws SecurityException if permission is denied
313       */
314      public static void setProperties(Properties properties)
315    {    {
316      Runtime.getRuntime ().runFinalization ();      SecurityManager sm = Runtime.getSecurityManager();
317        if (sm != null)
318          sm.checkPropertiesAccess();
319        // XXX Special case null
320        System.properties = properties;
321    }    }
322    
323          /** Tell the Runtime whether to run finalization before    /**
324           ** exiting the JVM.  Just uses     * Get a single system property by name. A security check may be performed,
325           ** <CODE>Runtime.getRuntime().runFinalizersOnExit()</CODE>.     * <code>checkPropertyAccess(key)</code>.
326           ** @see java.lang.Runtime#runFinalizersOnExit()     *
327           **     * @param key the name of the system property to get
328           ** @deprecated Since 1.2 this method is officially deprecated     * @return the property, or null if not found
329           ** because there is no guarantee and doing the actual finalization     * @throws SecurityException if permission is denied
330           ** on all objects is unsafe since not all (daemon) threads might     * @throws NullPointerException if key is null
331           ** be finished with all objects when the VM terminates.     * @throws IllegalArgumentException if key is ""
332           **/     */
333    public static void runFinalizersOnExit (boolean finalizeOnExit)    public static String getProperty(String key)
334    {    {
335      Runtime.getRuntime ().runFinalizersOnExit (finalizeOnExit);      SecurityManager sm = Runtime.getSecurityManager();
336    }      if (sm != null)
337          sm.checkPropertyAccess(key);
338          /** Helper method to load a library using its explicit      // XXX ensure properties is not null, and be thread-safe
339           ** system-dependent filename.  This just calls      return properties.getProperty(key);
340           ** <CODE>Runtime.getRuntime().load(filename)</CODE>.    }
341           ** @see java.lang.Runtime#load(java.lang.String)  
342           **/    /**
343    public static void load (String filename)     * Get a single system property by name. A security check may be performed,
344       * <code>checkPropertyAccess(key)</code>.
345       *
346       * @param key the name of the system property to get
347       * @param def the default
348       * @return the property, or def if not found
349       * @throws SecurityException if permission is denied
350       * @throws NullPointerException if key is null
351       * @throws IllegalArgumentException if key is ""
352       */
353      public static String getProperty(String key, String def)
354    {    {
355      Runtime.getRuntime ().load (filename);      SecurityManager sm = Runtime.getSecurityManager();
356    }      if (sm != null)
357          sm.checkPropertyAccess(key);
358          /** Helper method to load a library using just a      // XXX ensure properties is not null, and be thread-safe
359           ** short identifier for the name.  This just calls      return properties.getProperty(key, def);
360           ** <CODE>Runtime.getRuntime().loadLibrary(libname)</CODE>.    }
361           ** @see java.lang.Runtime#loadLibrary(java.lang.String)  
362           **/    /**
363    public static void loadLibrary (String libname)     * Set a single system property by name. A security check may be performed,
364       * <code>checkPropertyAccess(key, "write")</code>.
365       *
366       * @param key the name of the system property to set
367       * @param value the new value
368       * @return the previous value, or null
369       * @throws SecurityException if permission is denied
370       * @throws NullPointerException if key is null
371       * @throws IllegalArgumentException if key is ""
372       * @since 1.2
373       */
374      public static String setProperty(String key, String value)
375    {    {
376      Runtime.getRuntime ().loadLibrary (libname);      SecurityManager sm = Runtime.getSecurityManager();
377    }      if (sm != null)
378          sm.checkPermission(new PropertyPermission(key, "write"));
379    /** Add Classpath specific system properties.      // XXX ensure properties is not null, and be thread-safe
380     ** <br>      return (String) properties.setProperty(key, value);
381     ** Current properties:    }
382     ** <br>  
383     ** <ul>    /**
384     **   <li> gnu.cpu.endian - big or little</li>     * Get an environment variable. <b>WARNING</b>: This is not the preferred
385     ** </ul>     * way to check properties, nor is it guaranteed to work across all
386     **/     * implementations. Use <code>getProperty</code> instead.
387    static void insertGNUProperties ()     *
388       * @param name the name of the environment variable
389       * @return the value of the variable, or null
390       * @deprecated use {@link #getProperty(String)}
391       */
392      public static String getenv(String name)
393      {
394        //XXX This should be a native method, which actually uses getenv(3).
395        return getProperty(name);
396      }
397    
398      /**
399       * Terminate the Virtual Machine. This just calls
400       * <code>Runtime.getRuntime().exit(status)</code>, and never returns.
401       * Obviously, a security check is in order, <code>checkExit</code>.
402       *
403       * @param status the exit status; by convention non-zero is abnormal
404       * @throws SecurityException if permission is denied
405       * @see Runtime#exit(int)
406       */
407      public static void exit(int status)
408      {
409        Runtime.getRuntime().exit(status);
410      }
411    
412      /**
413       * Calls the garbage collector. This is only a hint, and it is up to the
414       * implementation what this hint suggests, but it usually causes a
415       * best-effort attempt to reclaim unused memory from discarded objects.
416       * This calls <code>Runtime.getRuntime().gc()</code>.
417       *
418       * @see Runtime#gc()
419       */
420      public static void gc()
421      {
422        Runtime.getRuntime().gc();
423      }
424    
425      /**
426       * Runs object finalization on pending objects. This is only a hint, and
427       * it is up to the implementation what this hint suggests, but it usually
428       * causes a best-effort attempt to run finalizers on all objects ready
429       * to be reclaimed. This calls
430       * <code>Runtime.getRuntime().runFinalization()</code>.
431       *
432       * @see Runtime#runFinalization()
433       */
434      public static void runFinalization()
435      {
436        Runtime.getRuntime().runFinalization();
437      }
438    
439      /**
440       * Tell the Runtime whether to run finalization before exiting the
441       * JVM.  This is inherently unsafe in multi-threaded applications,
442       * since it can force initialization on objects which are still in use
443       * by live threads, leading to deadlock; therefore this is disabled by
444       * default. There may be a security check, <code>checkExit(0)</code>. This
445       * calls <code>Runtime.getRuntime().runFinalizersOnExit()</code>.
446       *
447       * @param finalizeOnExit whether to run finalizers on exit
448       * @throws SecurityException if permission is denied
449       * @see Runtime#runFinalizersOnExit()
450       * @since 1.1
451       * @deprecated never rely on finalizers to do a clean, thread-safe,
452       *             mop-up from your code
453       */
454      public static void runFinalizersOnExit(boolean finalizeOnExit)
455      {
456    
457        Runtime.getRuntime().runFinalizersOnExit(finalizeOnExit);
458      }
459    
460      /**
461       * Load a code file using its explicit system-dependent filename. A security
462       * check may be performed, <code>checkLink</code>. This just calls
463       * <code>Runtime.getRuntime().load(filename)</code>.
464       *
465       * @param filename the code file to load
466       * @throws SecurityException if permission is denied
467       * @throws UnsatisfiedLinkError if the file cannot be loaded
468       * @see Runtime#load(String)
469       */
470      public static void load(String filename)
471      {
472        Runtime.getRuntime().load(filename);
473      }
474    
475      /**
476       * Load a library using its explicit system-dependent filename. A security
477       * check may be performed, <code>checkLink</code>. This just calls
478       * <code>Runtime.getRuntime().load(filename)</code>.
479       *
480       * @param libname the library file to load
481       * @throws SecurityException if permission is denied
482       * @throws UnsatisfiedLinkError if the file cannot be loaded
483       * @see Runtime#load(String)
484       */
485      public static void loadLibrary(String libname)
486      {
487        Runtime.getRuntime().loadLibrary(libname);
488      }
489    
490      /**
491       * Convert a library name to its platform-specific variant.
492       *
493       * @param libname the library name, as used in <code>loadLibrary</code>
494       * @return the platform-specific mangling of the name
495       * @since 1.2
496       * @XXX Add this method, and its support in VMSystem.
497      public static String mapLibraryName(String libname)
498      {
499        return VMSystem.mapLibraryName(libname);
500      }
501       */
502    
503      /**
504       * Add Classpath specific system properties.
505       * <br>
506       * Current properties:
507       * <br>
508       * <ul>
509       *   <li> gnu.cpu.endian - big or little</li>
510       *   <li> gnu.java.io.encoding_scheme_alias.ISO-8859-? - 8859_?</li>
511       *   <li> gnu.java.io.encoding_scheme_alias.iso-8859-? - 8859_?</li>
512       *   <li> gnu.java.io.encoding_scheme_alias.iso8859_? - 8859_?</li>
513       *   <li> gnu.java.io.encoding_scheme_alias.iso-latin-_? - 8859_?</li>
514       *   <li> gnu.java.io.encoding_scheme_alias.latin? - 8859_?</li>
515       *   <li> gnu.java.io.encoding_scheme_alias.UTF-8 - UTF8</li>
516       *   <li> gnu.java.io.encoding_scheme_alias.utf-8 - UTF8</li>
517       * </ul>
518       * @see gnu.java.io.EncodingManager
519       */
520      static void insertGNUProperties()
521    {    {
522      properties.put ("gnu.cpu.endian",      properties.put("gnu.cpu.endian",
523                      (isWordsBigEndian ())? "big" : "little");                     isWordsBigEndian() ? "big" : "little");
524    
525      // Common encoding aliases. See gnu.java.io.EncodingManager.      // Common encoding aliases. See gnu.java.io.EncodingManager.
526      properties.put ("gnu.java.io.encoding_scheme_alias.ISO-8859-1", "8859_1");      properties.put("gnu.java.io.encoding_scheme_alias.ISO-8859-1", "8859_1");
527      properties.put ("gnu.java.io.encoding_scheme_alias.ISO-8859-2", "8859_2");      properties.put("gnu.java.io.encoding_scheme_alias.ISO-8859-2", "8859_2");
528      properties.put ("gnu.java.io.encoding_scheme_alias.ISO-8859-3", "8859_3");      properties.put("gnu.java.io.encoding_scheme_alias.ISO-8859-3", "8859_3");
529      properties.put ("gnu.java.io.encoding_scheme_alias.ISO-8859-4", "8859_4");      properties.put("gnu.java.io.encoding_scheme_alias.ISO-8859-4", "8859_4");
530      properties.put ("gnu.java.io.encoding_scheme_alias.ISO-8859-5", "8859_5");      properties.put("gnu.java.io.encoding_scheme_alias.ISO-8859-5", "8859_5");
531      properties.put ("gnu.java.io.encoding_scheme_alias.ISO-8859-6", "8859_6");      properties.put("gnu.java.io.encoding_scheme_alias.ISO-8859-6", "8859_6");
532      properties.put ("gnu.java.io.encoding_scheme_alias.ISO-8859-7", "8859_7");      properties.put("gnu.java.io.encoding_scheme_alias.ISO-8859-7", "8859_7");
533      properties.put ("gnu.java.io.encoding_scheme_alias.ISO-8859-8", "8859_8");      properties.put("gnu.java.io.encoding_scheme_alias.ISO-8859-8", "8859_8");
534      properties.put ("gnu.java.io.encoding_scheme_alias.ISO-8859-9", "8859_9");      properties.put("gnu.java.io.encoding_scheme_alias.ISO-8859-9", "8859_9");
535    
536      properties.put ("gnu.java.io.encoding_scheme_alias.iso-8859-1", "8859_1");      properties.put("gnu.java.io.encoding_scheme_alias.iso-8859-1", "8859_1");
537      properties.put ("gnu.java.io.encoding_scheme_alias.iso-8859-2", "8859_2");      properties.put("gnu.java.io.encoding_scheme_alias.iso-8859-2", "8859_2");
538      properties.put ("gnu.java.io.encoding_scheme_alias.iso-8859-3", "8859_3");      properties.put("gnu.java.io.encoding_scheme_alias.iso-8859-3", "8859_3");
539      properties.put ("gnu.java.io.encoding_scheme_alias.iso-8859-4", "8859_4");      properties.put("gnu.java.io.encoding_scheme_alias.iso-8859-4", "8859_4");
540      properties.put ("gnu.java.io.encoding_scheme_alias.iso-8859-5", "8859_5");      properties.put("gnu.java.io.encoding_scheme_alias.iso-8859-5", "8859_5");
541      properties.put ("gnu.java.io.encoding_scheme_alias.iso-8859-6", "8859_6");      properties.put("gnu.java.io.encoding_scheme_alias.iso-8859-6", "8859_6");
542      properties.put ("gnu.java.io.encoding_scheme_alias.iso-8859-7", "8859_7");      properties.put("gnu.java.io.encoding_scheme_alias.iso-8859-7", "8859_7");
543      properties.put ("gnu.java.io.encoding_scheme_alias.iso-8859-8", "8859_8");      properties.put("gnu.java.io.encoding_scheme_alias.iso-8859-8", "8859_8");
544      properties.put ("gnu.java.io.encoding_scheme_alias.iso-8859-9", "8859_9");      properties.put("gnu.java.io.encoding_scheme_alias.iso-8859-9", "8859_9");
545    
546      properties.put ("gnu.java.io.encoding_scheme_alias.iso8859_1", "8859_1");      properties.put("gnu.java.io.encoding_scheme_alias.iso8859_1", "8859_1");
547      properties.put ("gnu.java.io.encoding_scheme_alias.iso8859_2", "8859_2");      properties.put("gnu.java.io.encoding_scheme_alias.iso8859_2", "8859_2");
548      properties.put ("gnu.java.io.encoding_scheme_alias.iso8859_3", "8859_3");      properties.put("gnu.java.io.encoding_scheme_alias.iso8859_3", "8859_3");
549      properties.put ("gnu.java.io.encoding_scheme_alias.iso8859_4", "8859_4");      properties.put("gnu.java.io.encoding_scheme_alias.iso8859_4", "8859_4");
550      properties.put ("gnu.java.io.encoding_scheme_alias.iso8859_5", "8859_5");      properties.put("gnu.java.io.encoding_scheme_alias.iso8859_5", "8859_5");
551      properties.put ("gnu.java.io.encoding_scheme_alias.iso8859_6", "8859_6");      properties.put("gnu.java.io.encoding_scheme_alias.iso8859_6", "8859_6");
552      properties.put ("gnu.java.io.encoding_scheme_alias.iso8859_7", "8859_7");      properties.put("gnu.java.io.encoding_scheme_alias.iso8859_7", "8859_7");
553      properties.put ("gnu.java.io.encoding_scheme_alias.iso8859_8", "8859_8");      properties.put("gnu.java.io.encoding_scheme_alias.iso8859_8", "8859_8");
554      properties.put ("gnu.java.io.encoding_scheme_alias.iso8859_9", "8859_9");      properties.put("gnu.java.io.encoding_scheme_alias.iso8859_9", "8859_9");
555    
556      properties.put ("gnu.java.io.encoding_scheme_alias.iso-latin-1", "8859_1");      properties.put("gnu.java.io.encoding_scheme_alias.iso-latin-1", "8859_1");
557      properties.put ("gnu.java.io.encoding_scheme_alias.iso-latin-2", "8859_2");      properties.put("gnu.java.io.encoding_scheme_alias.iso-latin-2", "8859_2");
558      properties.put ("gnu.java.io.encoding_scheme_alias.iso-latin-3", "8859_3");      properties.put("gnu.java.io.encoding_scheme_alias.iso-latin-3", "8859_3");
559      properties.put ("gnu.java.io.encoding_scheme_alias.iso-latin-4", "8859_4");      properties.put("gnu.java.io.encoding_scheme_alias.iso-latin-4", "8859_4");
560      properties.put ("gnu.java.io.encoding_scheme_alias.iso-latin-5", "8859_5");      properties.put("gnu.java.io.encoding_scheme_alias.iso-latin-5", "8859_5");
561      properties.put ("gnu.java.io.encoding_scheme_alias.iso-latin-6", "8859_6");      properties.put("gnu.java.io.encoding_scheme_alias.iso-latin-6", "8859_6");
562      properties.put ("gnu.java.io.encoding_scheme_alias.iso-latin-7", "8859_7");      properties.put("gnu.java.io.encoding_scheme_alias.iso-latin-7", "8859_7");
563      properties.put ("gnu.java.io.encoding_scheme_alias.iso-latin-8", "8859_8");      properties.put("gnu.java.io.encoding_scheme_alias.iso-latin-8", "8859_8");
564      properties.put ("gnu.java.io.encoding_scheme_alias.iso-latin-9", "8859_9");      properties.put("gnu.java.io.encoding_scheme_alias.iso-latin-9", "8859_9");
565    
566      properties.put ("gnu.java.io.encoding_scheme_alias.latin1", "8859_1");      properties.put("gnu.java.io.encoding_scheme_alias.latin1", "8859_1");
567      properties.put ("gnu.java.io.encoding_scheme_alias.latin2", "8859_2");      properties.put("gnu.java.io.encoding_scheme_alias.latin2", "8859_2");
568      properties.put ("gnu.java.io.encoding_scheme_alias.latin3", "8859_3");      properties.put("gnu.java.io.encoding_scheme_alias.latin3", "8859_3");
569      properties.put ("gnu.java.io.encoding_scheme_alias.latin4", "8859_4");      properties.put("gnu.java.io.encoding_scheme_alias.latin4", "8859_4");
570      properties.put ("gnu.java.io.encoding_scheme_alias.latin5", "8859_5");      properties.put("gnu.java.io.encoding_scheme_alias.latin5", "8859_5");
571      properties.put ("gnu.java.io.encoding_scheme_alias.latin6", "8859_6");      properties.put("gnu.java.io.encoding_scheme_alias.latin6", "8859_6");
572      properties.put ("gnu.java.io.encoding_scheme_alias.latin7", "8859_7");      properties.put("gnu.java.io.encoding_scheme_alias.latin7", "8859_7");
573      properties.put ("gnu.java.io.encoding_scheme_alias.latin8", "8859_8");      properties.put("gnu.java.io.encoding_scheme_alias.latin8", "8859_8");
574      properties.put ("gnu.java.io.encoding_scheme_alias.latin9", "8859_9");      properties.put("gnu.java.io.encoding_scheme_alias.latin9", "8859_9");
575    
576      properties.put ("gnu.java.io.encoding_scheme_alias.UTF-8", "UTF8");      properties.put("gnu.java.io.encoding_scheme_alias.UTF-8", "UTF8");
577      properties.put ("gnu.java.io.encoding_scheme_alias.utf-8", "UTF8");      properties.put("gnu.java.io.encoding_scheme_alias.utf-8", "UTF8");
578    }    }
579    
580    static native boolean isWordsBigEndian ();    /**
581       * Detect big-endian systems.
582       *
583       * @return true if the system is big-endian.
584       */
585      static native boolean isWordsBigEndian();
586  }  }

Legend:
Removed from v.1.13  
changed lines
  Added in v.1.14

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