src/java.base/share/classes/java/lang/System.java
changeset 49203 3a225d9cabe1
parent 49001 ce06058197a4
child 50531 aeb7fb702890
equal deleted inserted replaced
49202:b6fb84357542 49203:3a225d9cabe1
    72 import sun.reflect.annotation.AnnotationType;
    72 import sun.reflect.annotation.AnnotationType;
    73 import sun.nio.ch.Interruptible;
    73 import sun.nio.ch.Interruptible;
    74 import sun.security.util.SecurityConstants;
    74 import sun.security.util.SecurityConstants;
    75 
    75 
    76 /**
    76 /**
    77  * The <code>System</code> class contains several useful class fields
    77  * The {@code System} class contains several useful class fields
    78  * and methods. It cannot be instantiated.
    78  * and methods. It cannot be instantiated.
    79  *
    79  *
    80  * <p>Among the facilities provided by the <code>System</code> class
    80  * Among the facilities provided by the {@code System} class
    81  * are standard input, standard output, and error output streams;
    81  * are standard input, standard output, and error output streams;
    82  * access to externally defined properties and environment
    82  * access to externally defined properties and environment
    83  * variables; a means of loading files and libraries; and a utility
    83  * variables; a means of loading files and libraries; and a utility
    84  * method for quickly copying a portion of an array.
    84  * method for quickly copying a portion of an array.
    85  *
    85  *
    86  * @author  unascribed
       
    87  * @since   1.0
    86  * @since   1.0
    88  */
    87  */
    89 public final class System {
    88 public final class System {
    90     /* register the natives via the static initializer.
    89     /* Register the natives via the static initializer.
    91      *
    90      *
    92      * VM will invoke the initializeSystemClass method to complete
    91      * VM will invoke the initializeSystemClass method to complete
    93      * the initialization for this class separated from clinit.
    92      * the initialization for this class separated from clinit.
    94      * Note that to use properties set by the VM, see the constraints
    93      * Note that to use properties set by the VM, see the constraints
    95      * described in the initializeSystemClass method.
    94      * described in the initializeSystemClass method.
   121      * a line of output data is:
   120      * a line of output data is:
   122      * <blockquote><pre>
   121      * <blockquote><pre>
   123      *     System.out.println(data)
   122      *     System.out.println(data)
   124      * </pre></blockquote>
   123      * </pre></blockquote>
   125      * <p>
   124      * <p>
   126      * See the <code>println</code> methods in class <code>PrintStream</code>.
   125      * See the {@code println} methods in class {@code PrintStream}.
   127      *
   126      *
   128      * @see     java.io.PrintStream#println()
   127      * @see     java.io.PrintStream#println()
   129      * @see     java.io.PrintStream#println(boolean)
   128      * @see     java.io.PrintStream#println(boolean)
   130      * @see     java.io.PrintStream#println(char)
   129      * @see     java.io.PrintStream#println(char)
   131      * @see     java.io.PrintStream#println(char[])
   130      * @see     java.io.PrintStream#println(char[])
   145      * Typically this stream corresponds to display output or another
   144      * Typically this stream corresponds to display output or another
   146      * output destination specified by the host environment or user. By
   145      * output destination specified by the host environment or user. By
   147      * convention, this output stream is used to display error messages
   146      * convention, this output stream is used to display error messages
   148      * or other information that should come to the immediate attention
   147      * or other information that should come to the immediate attention
   149      * of a user even if the principal output stream, the value of the
   148      * of a user even if the principal output stream, the value of the
   150      * variable <code>out</code>, has been redirected to a file or other
   149      * variable {@code out}, has been redirected to a file or other
   151      * destination that is typically not continuously monitored.
   150      * destination that is typically not continuously monitored.
   152      */
   151      */
   153     public static final PrintStream err = null;
   152     public static final PrintStream err = null;
   154 
   153 
   155     /* The security manager for the system.
   154     /* The security manager for the system.
   157     private static volatile SecurityManager security;
   156     private static volatile SecurityManager security;
   158 
   157 
   159     /**
   158     /**
   160      * Reassigns the "standard" input stream.
   159      * Reassigns the "standard" input stream.
   161      *
   160      *
   162      * <p>First, if there is a security manager, its <code>checkPermission</code>
   161      * First, if there is a security manager, its {@code checkPermission}
   163      * method is called with a <code>RuntimePermission("setIO")</code> permission
   162      * method is called with a {@code RuntimePermission("setIO")} permission
   164      *  to see if it's ok to reassign the "standard" input stream.
   163      *  to see if it's ok to reassign the "standard" input stream.
   165      *
   164      *
   166      * @param in the new standard input stream.
   165      * @param in the new standard input stream.
   167      *
   166      *
   168      * @throws SecurityException
   167      * @throws SecurityException
   169      *        if a security manager exists and its
   168      *        if a security manager exists and its
   170      *        <code>checkPermission</code> method doesn't allow
   169      *        {@code checkPermission} method doesn't allow
   171      *        reassigning of the standard input stream.
   170      *        reassigning of the standard input stream.
   172      *
   171      *
   173      * @see SecurityManager#checkPermission
   172      * @see SecurityManager#checkPermission
   174      * @see java.lang.RuntimePermission
   173      * @see java.lang.RuntimePermission
   175      *
   174      *
   181     }
   180     }
   182 
   181 
   183     /**
   182     /**
   184      * Reassigns the "standard" output stream.
   183      * Reassigns the "standard" output stream.
   185      *
   184      *
   186      * <p>First, if there is a security manager, its <code>checkPermission</code>
   185      * First, if there is a security manager, its {@code checkPermission}
   187      * method is called with a <code>RuntimePermission("setIO")</code> permission
   186      * method is called with a {@code RuntimePermission("setIO")} permission
   188      *  to see if it's ok to reassign the "standard" output stream.
   187      *  to see if it's ok to reassign the "standard" output stream.
   189      *
   188      *
   190      * @param out the new standard output stream
   189      * @param out the new standard output stream
   191      *
   190      *
   192      * @throws SecurityException
   191      * @throws SecurityException
   193      *        if a security manager exists and its
   192      *        if a security manager exists and its
   194      *        <code>checkPermission</code> method doesn't allow
   193      *        {@code checkPermission} method doesn't allow
   195      *        reassigning of the standard output stream.
   194      *        reassigning of the standard output stream.
   196      *
   195      *
   197      * @see SecurityManager#checkPermission
   196      * @see SecurityManager#checkPermission
   198      * @see java.lang.RuntimePermission
   197      * @see java.lang.RuntimePermission
   199      *
   198      *
   205     }
   204     }
   206 
   205 
   207     /**
   206     /**
   208      * Reassigns the "standard" error output stream.
   207      * Reassigns the "standard" error output stream.
   209      *
   208      *
   210      * <p>First, if there is a security manager, its <code>checkPermission</code>
   209      * First, if there is a security manager, its {@code checkPermission}
   211      * method is called with a <code>RuntimePermission("setIO")</code> permission
   210      * method is called with a {@code RuntimePermission("setIO")} permission
   212      *  to see if it's ok to reassign the "standard" error output stream.
   211      *  to see if it's ok to reassign the "standard" error output stream.
   213      *
   212      *
   214      * @param err the new standard error output stream.
   213      * @param err the new standard error output stream.
   215      *
   214      *
   216      * @throws SecurityException
   215      * @throws SecurityException
   217      *        if a security manager exists and its
   216      *        if a security manager exists and its
   218      *        <code>checkPermission</code> method doesn't allow
   217      *        {@code checkPermission} method doesn't allow
   219      *        reassigning of the standard error output stream.
   218      *        reassigning of the standard error output stream.
   220      *
   219      *
   221      * @see SecurityManager#checkPermission
   220      * @see SecurityManager#checkPermission
   222      * @see java.lang.RuntimePermission
   221      * @see java.lang.RuntimePermission
   223      *
   222      *
   251 
   250 
   252     /**
   251     /**
   253      * Returns the channel inherited from the entity that created this
   252      * Returns the channel inherited from the entity that created this
   254      * Java virtual machine.
   253      * Java virtual machine.
   255      *
   254      *
   256      * <p> This method returns the channel obtained by invoking the
   255      * This method returns the channel obtained by invoking the
   257      * {@link java.nio.channels.spi.SelectorProvider#inheritedChannel
   256      * {@link java.nio.channels.spi.SelectorProvider#inheritedChannel
   258      * inheritedChannel} method of the system-wide default
   257      * inheritedChannel} method of the system-wide default
   259      * {@link java.nio.channels.spi.SelectorProvider} object. </p>
   258      * {@link java.nio.channels.spi.SelectorProvider} object.
   260      *
   259      *
   261      * <p> In addition to the network-oriented channels described in
   260      * <p> In addition to the network-oriented channels described in
   262      * {@link java.nio.channels.spi.SelectorProvider#inheritedChannel
   261      * {@link java.nio.channels.spi.SelectorProvider#inheritedChannel
   263      * inheritedChannel}, this method may return other kinds of
   262      * inheritedChannel}, this method may return other kinds of
   264      * channels in the future.
   263      * channels in the future.
   290     private static native void setErr0(PrintStream err);
   289     private static native void setErr0(PrintStream err);
   291 
   290 
   292     /**
   291     /**
   293      * Sets the System security.
   292      * Sets the System security.
   294      *
   293      *
   295      * <p> If there is a security manager already installed, this method first
   294      * If there is a security manager already installed, this method first
   296      * calls the security manager's <code>checkPermission</code> method
   295      * calls the security manager's {@code checkPermission} method
   297      * with a <code>RuntimePermission("setSecurityManager")</code>
   296      * with a {@code RuntimePermission("setSecurityManager")}
   298      * permission to ensure it's ok to replace the existing
   297      * permission to ensure it's ok to replace the existing
   299      * security manager.
   298      * security manager.
   300      * This may result in throwing a <code>SecurityException</code>.
   299      * This may result in throwing a {@code SecurityException}.
   301      *
   300      *
   302      * <p> Otherwise, the argument is established as the current
   301      * <p> Otherwise, the argument is established as the current
   303      * security manager. If the argument is <code>null</code> and no
   302      * security manager. If the argument is {@code null} and no
   304      * security manager has been established, then no action is taken and
   303      * security manager has been established, then no action is taken and
   305      * the method simply returns.
   304      * the method simply returns.
   306      *
   305      *
   307      * @param      s   the security manager.
   306      * @param      s   the security manager.
   308      * @exception  SecurityException  if the security manager has already
   307      * @throws     SecurityException  if the security manager has already
   309      *             been set and its <code>checkPermission</code> method
   308      *             been set and its {@code checkPermission} method
   310      *             doesn't allow it to be replaced.
   309      *             doesn't allow it to be replaced.
   311      * @see #getSecurityManager
   310      * @see #getSecurityManager
   312      * @see SecurityManager#checkPermission
   311      * @see SecurityManager#checkPermission
   313      * @see java.lang.RuntimePermission
   312      * @see java.lang.RuntimePermission
   314      */
   313      */
   361     /**
   360     /**
   362      * Gets the system security interface.
   361      * Gets the system security interface.
   363      *
   362      *
   364      * @return  if a security manager has already been established for the
   363      * @return  if a security manager has already been established for the
   365      *          current application, then that security manager is returned;
   364      *          current application, then that security manager is returned;
   366      *          otherwise, <code>null</code> is returned.
   365      *          otherwise, {@code null} is returned.
   367      * @see     #setSecurityManager
   366      * @see     #setSecurityManager
   368      */
   367      */
   369     public static SecurityManager getSecurityManager() {
   368     public static SecurityManager getSecurityManager() {
   370         return security;
   369         return security;
   371     }
   370     }
   376      * the granularity of the value depends on the underlying
   375      * the granularity of the value depends on the underlying
   377      * operating system and may be larger.  For example, many
   376      * operating system and may be larger.  For example, many
   378      * operating systems measure time in units of tens of
   377      * operating systems measure time in units of tens of
   379      * milliseconds.
   378      * milliseconds.
   380      *
   379      *
   381      * <p> See the description of the class <code>Date</code> for
   380      * <p> See the description of the class {@code Date} for
   382      * a discussion of slight discrepancies that may arise between
   381      * a discussion of slight discrepancies that may arise between
   383      * "computer time" and coordinated universal time (UTC).
   382      * "computer time" and coordinated universal time (UTC).
   384      *
   383      *
   385      * @return  the difference, measured in milliseconds, between
   384      * @return  the difference, measured in milliseconds, between
   386      *          the current time and midnight, January 1, 1970 UTC.
   385      *          the current time and midnight, January 1, 1970 UTC.
   391 
   390 
   392     /**
   391     /**
   393      * Returns the current value of the running Java Virtual Machine's
   392      * Returns the current value of the running Java Virtual Machine's
   394      * high-resolution time source, in nanoseconds.
   393      * high-resolution time source, in nanoseconds.
   395      *
   394      *
   396      * <p>This method can only be used to measure elapsed time and is
   395      * This method can only be used to measure elapsed time and is
   397      * not related to any other notion of system or wall-clock time.
   396      * not related to any other notion of system or wall-clock time.
   398      * The value returned represents nanoseconds since some fixed but
   397      * The value returned represents nanoseconds since some fixed but
   399      * arbitrary <i>origin</i> time (perhaps in the future, so values
   398      * arbitrary <i>origin</i> time (perhaps in the future, so values
   400      * may be negative).  The same origin is used by all invocations of
   399      * may be negative).  The same origin is used by all invocations of
   401      * this method in an instance of a Java virtual machine; other
   400      * this method in an instance of a Java virtual machine; other
   435 
   434 
   436     /**
   435     /**
   437      * Copies an array from the specified source array, beginning at the
   436      * Copies an array from the specified source array, beginning at the
   438      * specified position, to the specified position of the destination array.
   437      * specified position, to the specified position of the destination array.
   439      * A subsequence of array components are copied from the source
   438      * A subsequence of array components are copied from the source
   440      * array referenced by <code>src</code> to the destination array
   439      * array referenced by {@code src} to the destination array
   441      * referenced by <code>dest</code>. The number of components copied is
   440      * referenced by {@code dest}. The number of components copied is
   442      * equal to the <code>length</code> argument. The components at
   441      * equal to the {@code length} argument. The components at
   443      * positions <code>srcPos</code> through
   442      * positions {@code srcPos} through
   444      * <code>srcPos+length-1</code> in the source array are copied into
   443      * {@code srcPos+length-1} in the source array are copied into
   445      * positions <code>destPos</code> through
   444      * positions {@code destPos} through
   446      * <code>destPos+length-1</code>, respectively, of the destination
   445      * {@code destPos+length-1}, respectively, of the destination
   447      * array.
   446      * array.
   448      * <p>
   447      * <p>
   449      * If the <code>src</code> and <code>dest</code> arguments refer to the
   448      * If the {@code src} and {@code dest} arguments refer to the
   450      * same array object, then the copying is performed as if the
   449      * same array object, then the copying is performed as if the
   451      * components at positions <code>srcPos</code> through
   450      * components at positions {@code srcPos} through
   452      * <code>srcPos+length-1</code> were first copied to a temporary
   451      * {@code srcPos+length-1} were first copied to a temporary
   453      * array with <code>length</code> components and then the contents of
   452      * array with {@code length} components and then the contents of
   454      * the temporary array were copied into positions
   453      * the temporary array were copied into positions
   455      * <code>destPos</code> through <code>destPos+length-1</code> of the
   454      * {@code destPos} through {@code destPos+length-1} of the
   456      * destination array.
   455      * destination array.
   457      * <p>
   456      * <p>
   458      * If <code>dest</code> is <code>null</code>, then a
   457      * If {@code dest} is {@code null}, then a
   459      * <code>NullPointerException</code> is thrown.
   458      * {@code NullPointerException} is thrown.
   460      * <p>
   459      * <p>
   461      * If <code>src</code> is <code>null</code>, then a
   460      * If {@code src} is {@code null}, then a
   462      * <code>NullPointerException</code> is thrown and the destination
   461      * {@code NullPointerException} is thrown and the destination
   463      * array is not modified.
   462      * array is not modified.
   464      * <p>
   463      * <p>
   465      * Otherwise, if any of the following is true, an
   464      * Otherwise, if any of the following is true, an
   466      * <code>ArrayStoreException</code> is thrown and the destination is
   465      * {@code ArrayStoreException} is thrown and the destination is
   467      * not modified:
   466      * not modified:
   468      * <ul>
   467      * <ul>
   469      * <li>The <code>src</code> argument refers to an object that is not an
   468      * <li>The {@code src} argument refers to an object that is not an
   470      *     array.
   469      *     array.
   471      * <li>The <code>dest</code> argument refers to an object that is not an
   470      * <li>The {@code dest} argument refers to an object that is not an
   472      *     array.
   471      *     array.
   473      * <li>The <code>src</code> argument and <code>dest</code> argument refer
   472      * <li>The {@code src} argument and {@code dest} argument refer
   474      *     to arrays whose component types are different primitive types.
   473      *     to arrays whose component types are different primitive types.
   475      * <li>The <code>src</code> argument refers to an array with a primitive
   474      * <li>The {@code src} argument refers to an array with a primitive
   476      *    component type and the <code>dest</code> argument refers to an array
   475      *    component type and the {@code dest} argument refers to an array
   477      *     with a reference component type.
   476      *     with a reference component type.
   478      * <li>The <code>src</code> argument refers to an array with a reference
   477      * <li>The {@code src} argument refers to an array with a reference
   479      *    component type and the <code>dest</code> argument refers to an array
   478      *    component type and the {@code dest} argument refers to an array
   480      *     with a primitive component type.
   479      *     with a primitive component type.
   481      * </ul>
   480      * </ul>
   482      * <p>
   481      * <p>
   483      * Otherwise, if any of the following is true, an
   482      * Otherwise, if any of the following is true, an
   484      * <code>IndexOutOfBoundsException</code> is
   483      * {@code IndexOutOfBoundsException} is
   485      * thrown and the destination is not modified:
   484      * thrown and the destination is not modified:
   486      * <ul>
   485      * <ul>
   487      * <li>The <code>srcPos</code> argument is negative.
   486      * <li>The {@code srcPos} argument is negative.
   488      * <li>The <code>destPos</code> argument is negative.
   487      * <li>The {@code destPos} argument is negative.
   489      * <li>The <code>length</code> argument is negative.
   488      * <li>The {@code length} argument is negative.
   490      * <li><code>srcPos+length</code> is greater than
   489      * <li>{@code srcPos+length} is greater than
   491      *     <code>src.length</code>, the length of the source array.
   490      *     {@code src.length}, the length of the source array.
   492      * <li><code>destPos+length</code> is greater than
   491      * <li>{@code destPos+length} is greater than
   493      *     <code>dest.length</code>, the length of the destination array.
   492      *     {@code dest.length}, the length of the destination array.
   494      * </ul>
   493      * </ul>
   495      * <p>
   494      * <p>
   496      * Otherwise, if any actual component of the source array from
   495      * Otherwise, if any actual component of the source array from
   497      * position <code>srcPos</code> through
   496      * position {@code srcPos} through
   498      * <code>srcPos+length-1</code> cannot be converted to the component
   497      * {@code srcPos+length-1} cannot be converted to the component
   499      * type of the destination array by assignment conversion, an
   498      * type of the destination array by assignment conversion, an
   500      * <code>ArrayStoreException</code> is thrown. In this case, let
   499      * {@code ArrayStoreException} is thrown. In this case, let
   501      * <b><i>k</i></b> be the smallest nonnegative integer less than
   500      * <b><i>k</i></b> be the smallest nonnegative integer less than
   502      * length such that <code>src[srcPos+</code><i>k</i><code>]</code>
   501      * length such that {@code src[srcPos+}<i>k</i>{@code ]}
   503      * cannot be converted to the component type of the destination
   502      * cannot be converted to the component type of the destination
   504      * array; when the exception is thrown, source array components from
   503      * array; when the exception is thrown, source array components from
   505      * positions <code>srcPos</code> through
   504      * positions {@code srcPos} through
   506      * <code>srcPos+</code><i>k</i><code>-1</code>
   505      * {@code srcPos+}<i>k</i>{@code -1}
   507      * will already have been copied to destination array positions
   506      * will already have been copied to destination array positions
   508      * <code>destPos</code> through
   507      * {@code destPos} through
   509      * <code>destPos+</code><i>k</I><code>-1</code> and no other
   508      * {@code destPos+}<i>k</I>{@code -1} and no other
   510      * positions of the destination array will have been modified.
   509      * positions of the destination array will have been modified.
   511      * (Because of the restrictions already itemized, this
   510      * (Because of the restrictions already itemized, this
   512      * paragraph effectively applies only to the situation where both
   511      * paragraph effectively applies only to the situation where both
   513      * arrays have component types that are reference types.)
   512      * arrays have component types that are reference types.)
   514      *
   513      *
   515      * @param      src      the source array.
   514      * @param      src      the source array.
   516      * @param      srcPos   starting position in the source array.
   515      * @param      srcPos   starting position in the source array.
   517      * @param      dest     the destination array.
   516      * @param      dest     the destination array.
   518      * @param      destPos  starting position in the destination data.
   517      * @param      destPos  starting position in the destination data.
   519      * @param      length   the number of array elements to be copied.
   518      * @param      length   the number of array elements to be copied.
   520      * @exception  IndexOutOfBoundsException  if copying would cause
   519      * @throws     IndexOutOfBoundsException  if copying would cause
   521      *               access of data outside array bounds.
   520      *             access of data outside array bounds.
   522      * @exception  ArrayStoreException  if an element in the <code>src</code>
   521      * @throws     ArrayStoreException  if an element in the {@code src}
   523      *               array could not be stored into the <code>dest</code> array
   522      *             array could not be stored into the {@code dest} array
   524      *               because of a type mismatch.
   523      *             because of a type mismatch.
   525      * @exception  NullPointerException if either <code>src</code> or
   524      * @throws     NullPointerException if either {@code src} or
   526      *               <code>dest</code> is <code>null</code>.
   525      *             {@code dest} is {@code null}.
   527      */
   526      */
   528     @HotSpotIntrinsicCandidate
   527     @HotSpotIntrinsicCandidate
   529     public static native void arraycopy(Object src,  int  srcPos,
   528     public static native void arraycopy(Object src,  int  srcPos,
   530                                         Object dest, int destPos,
   529                                         Object dest, int destPos,
   531                                         int length);
   530                                         int length);
   572     private static Properties props;
   571     private static Properties props;
   573     private static native Properties initProperties(Properties props);
   572     private static native Properties initProperties(Properties props);
   574 
   573 
   575     /**
   574     /**
   576      * Determines the current system properties.
   575      * Determines the current system properties.
   577      * <p>
   576      *
   578      * First, if there is a security manager, its
   577      * First, if there is a security manager, its
   579      * <code>checkPropertiesAccess</code> method is called with no
   578      * {@code checkPropertiesAccess} method is called with no
   580      * arguments. This may result in a security exception.
   579      * arguments. This may result in a security exception.
   581      * <p>
   580      * <p>
   582      * The current set of system properties for use by the
   581      * The current set of system properties for use by the
   583      * {@link #getProperty(String)} method is returned as a
   582      * {@link #getProperty(String)} method is returned as a
   584      * <code>Properties</code> object. If there is no current set of
   583      * {@code Properties} object. If there is no current set of
   585      * system properties, a set of system properties is first created and
   584      * system properties, a set of system properties is first created and
   586      * initialized. This set of system properties always includes values
   585      * initialized. This set of system properties always includes values
   587      * for the following keys:
   586      * for the following keys:
   588      * <table class="striped" style="text-align:left">
   587      * <table class="striped" style="text-align:left">
   589      * <caption style="display:none">Shows property keys and associated values</caption>
   588      * <caption style="display:none">Shows property keys and associated values</caption>
   590      * <thead>
   589      * <thead>
   591      * <tr><th scope="col">Key</th>
   590      * <tr><th scope="col">Key</th>
   592      *     <th scope="col">Description of Associated Value</th></tr>
   591      *     <th scope="col">Description of Associated Value</th></tr>
   593      * </thead>
   592      * </thead>
   594      * <tbody>
   593      * <tbody>
   595      * <tr><th scope="row"><code>java.version</code></th>
   594      * <tr><th scope="row">{@code java.version}</th>
   596      *     <td>Java Runtime Environment version, which may be interpreted
   595      *     <td>Java Runtime Environment version, which may be interpreted
   597      *     as a {@link Runtime.Version}</td></tr>
   596      *     as a {@link Runtime.Version}</td></tr>
   598      * <tr><th scope="row"><code>java.version.date</code></th>
   597      * <tr><th scope="row">{@code java.version.date}</th>
   599      *     <td>Java Runtime Environment version date, in ISO-8601 YYYY-MM-DD
   598      *     <td>Java Runtime Environment version date, in ISO-8601 YYYY-MM-DD
   600      *     format, which may be interpreted as a {@link
   599      *     format, which may be interpreted as a {@link
   601      *     java.time.LocalDate}</td></tr>
   600      *     java.time.LocalDate}</td></tr>
   602      * <tr><th scope="row"><code>java.vendor</code></th>
   601      * <tr><th scope="row">{@code java.vendor}</th>
   603      *     <td>Java Runtime Environment vendor</td></tr>
   602      *     <td>Java Runtime Environment vendor</td></tr>
   604      * <tr><th scope="row"><code>java.vendor.url</code></th>
   603      * <tr><th scope="row">{@code java.vendor.url}</th>
   605      *     <td>Java vendor URL</td></tr>
   604      *     <td>Java vendor URL</td></tr>
   606      * <tr><th scope="row"><code>java.vendor.version</code></th>
   605      * <tr><th scope="row">{@code java.vendor.version}</th>
   607      *     <td>Java vendor version</td></tr>
   606      *     <td>Java vendor version</td></tr>
   608      * <tr><th scope="row"><code>java.home</code></th>
   607      * <tr><th scope="row">{@code java.home}</th>
   609      *     <td>Java installation directory</td></tr>
   608      *     <td>Java installation directory</td></tr>
   610      * <tr><th scope="row"><code>java.vm.specification.version</code></th>
   609      * <tr><th scope="row">{@code java.vm.specification.version}</th>
   611      *     <td>Java Virtual Machine specification version which may be
   610      *     <td>Java Virtual Machine specification version which may be
   612      *     interpreted as a {@link Runtime.Version}</td></tr>
   611      *     interpreted as a {@link Runtime.Version}</td></tr>
   613      * <tr><th scope="row"><code>java.vm.specification.vendor</code></th>
   612      * <tr><th scope="row">{@code java.vm.specification.vendor}</th>
   614      *     <td>Java Virtual Machine specification vendor</td></tr>
   613      *     <td>Java Virtual Machine specification vendor</td></tr>
   615      * <tr><th scope="row"><code>java.vm.specification.name</code></th>
   614      * <tr><th scope="row">{@code java.vm.specification.name}</th>
   616      *     <td>Java Virtual Machine specification name</td></tr>
   615      *     <td>Java Virtual Machine specification name</td></tr>
   617      * <tr><th scope="row"><code>java.vm.version</code></th>
   616      * <tr><th scope="row">{@code java.vm.version}</th>
   618      *     <td>Java Virtual Machine implementation version which may be
   617      *     <td>Java Virtual Machine implementation version which may be
   619      *     interpreted as a {@link Runtime.Version}</td></tr>
   618      *     interpreted as a {@link Runtime.Version}</td></tr>
   620      * <tr><th scope="row"><code>java.vm.vendor</code></th>
   619      * <tr><th scope="row">{@code java.vm.vendor}</th>
   621      *     <td>Java Virtual Machine implementation vendor</td></tr>
   620      *     <td>Java Virtual Machine implementation vendor</td></tr>
   622      * <tr><th scope="row"><code>java.vm.name</code></th>
   621      * <tr><th scope="row">{@code java.vm.name}</th>
   623      *     <td>Java Virtual Machine implementation name</td></tr>
   622      *     <td>Java Virtual Machine implementation name</td></tr>
   624      * <tr><th scope="row"><code>java.specification.version</code></th>
   623      * <tr><th scope="row">{@code java.specification.version}</th>
   625      *     <td>Java Runtime Environment specification version which may be
   624      *     <td>Java Runtime Environment specification version which may be
   626      *     interpreted as a {@link Runtime.Version}</td></tr>
   625      *     interpreted as a {@link Runtime.Version}</td></tr>
   627      * <tr><th scope="row"><code>java.specification.vendor</code></th>
   626      * <tr><th scope="row">{@code java.specification.vendor}</th>
   628      *     <td>Java Runtime Environment specification  vendor</td></tr>
   627      *     <td>Java Runtime Environment specification  vendor</td></tr>
   629      * <tr><th scope="row"><code>java.specification.name</code></th>
   628      * <tr><th scope="row">{@code java.specification.name}</th>
   630      *     <td>Java Runtime Environment specification  name</td></tr>
   629      *     <td>Java Runtime Environment specification  name</td></tr>
   631      * <tr><th scope="row"><code>java.class.version</code></th>
   630      * <tr><th scope="row">{@code java.class.version}</th>
   632      *     <td>Java class format version number</td></tr>
   631      *     <td>Java class format version number</td></tr>
   633      * <tr><th scope="row"><code>java.class.path</code></th>
   632      * <tr><th scope="row">{@code java.class.path}</th>
   634      *     <td>Java class path  (refer to
   633      *     <td>Java class path  (refer to
   635      *        {@link ClassLoader#getSystemClassLoader()} for details)</td></tr>
   634      *        {@link ClassLoader#getSystemClassLoader()} for details)</td></tr>
   636      * <tr><th scope="row"><code>java.library.path</code></th>
   635      * <tr><th scope="row">{@code java.library.path}</th>
   637      *     <td>List of paths to search when loading libraries</td></tr>
   636      *     <td>List of paths to search when loading libraries</td></tr>
   638      * <tr><th scope="row"><code>java.io.tmpdir</code></th>
   637      * <tr><th scope="row">{@code java.io.tmpdir}</th>
   639      *     <td>Default temp file path</td></tr>
   638      *     <td>Default temp file path</td></tr>
   640      * <tr><th scope="row"><code>java.compiler</code></th>
   639      * <tr><th scope="row">{@code java.compiler}</th>
   641      *     <td>Name of JIT compiler to use</td></tr>
   640      *     <td>Name of JIT compiler to use</td></tr>
   642      * <tr><th scope="row"><code>os.name</code></th>
   641      * <tr><th scope="row">{@code os.name}</th>
   643      *     <td>Operating system name</td></tr>
   642      *     <td>Operating system name</td></tr>
   644      * <tr><th scope="row"><code>os.arch</code></th>
   643      * <tr><th scope="row">{@code os.arch}</th>
   645      *     <td>Operating system architecture</td></tr>
   644      *     <td>Operating system architecture</td></tr>
   646      * <tr><th scope="row"><code>os.version</code></th>
   645      * <tr><th scope="row">{@code os.version}</th>
   647      *     <td>Operating system version</td></tr>
   646      *     <td>Operating system version</td></tr>
   648      * <tr><th scope="row"><code>file.separator</code></th>
   647      * <tr><th scope="row">{@code file.separator}</th>
   649      *     <td>File separator ("/" on UNIX)</td></tr>
   648      *     <td>File separator ("/" on UNIX)</td></tr>
   650      * <tr><th scope="row"><code>path.separator</code></th>
   649      * <tr><th scope="row">{@code path.separator}</th>
   651      *     <td>Path separator (":" on UNIX)</td></tr>
   650      *     <td>Path separator (":" on UNIX)</td></tr>
   652      * <tr><th scope="row"><code>line.separator</code></th>
   651      * <tr><th scope="row">{@code line.separator}</th>
   653      *     <td>Line separator ("\n" on UNIX)</td></tr>
   652      *     <td>Line separator ("\n" on UNIX)</td></tr>
   654      * <tr><th scope="row"><code>user.name</code></th>
   653      * <tr><th scope="row">{@code user.name}</th>
   655      *     <td>User's account name</td></tr>
   654      *     <td>User's account name</td></tr>
   656      * <tr><th scope="row"><code>user.home</code></th>
   655      * <tr><th scope="row">{@code user.home}</th>
   657      *     <td>User's home directory</td></tr>
   656      *     <td>User's home directory</td></tr>
   658      * <tr><th scope="row"><code>user.dir</code></th>
   657      * <tr><th scope="row">{@code user.dir}</th>
   659      *     <td>User's current working directory</td></tr>
   658      *     <td>User's current working directory</td></tr>
   660      * </tbody>
   659      * </tbody>
   661      * </table>
   660      * </table>
   662      * <p>
   661      * <p>
   663      * Multiple paths in a system property value are separated by the path
   662      * Multiple paths in a system property value are separated by the path
   664      * separator character of the platform.
   663      * separator character of the platform.
   665      * <p>
   664      * <p>
   666      * Note that even if the security manager does not permit the
   665      * Note that even if the security manager does not permit the
   667      * <code>getProperties</code> operation, it may choose to permit the
   666      * {@code getProperties} operation, it may choose to permit the
   668      * {@link #getProperty(String)} operation.
   667      * {@link #getProperty(String)} operation.
   669      *
   668      *
   670      * @implNote In addition to the standard system properties, the system
   669      * @implNote In addition to the standard system properties, the system
   671      * properties may include the following keys:
   670      * properties may include the following keys:
   672      * <table class="striped">
   671      * <table class="striped">
   686      *     <td>The main class name of the initial module</td></tr>
   685      *     <td>The main class name of the initial module</td></tr>
   687      * </tbody>
   686      * </tbody>
   688      * </table>
   687      * </table>
   689      *
   688      *
   690      * @return     the system properties
   689      * @return     the system properties
   691      * @exception  SecurityException  if a security manager exists and its
   690      * @throws     SecurityException  if a security manager exists and its
   692      *             <code>checkPropertiesAccess</code> method doesn't allow access
   691      *             {@code checkPropertiesAccess} method doesn't allow access
   693      *              to the system properties.
   692      *             to the system properties.
   694      * @see        #setProperties
   693      * @see        #setProperties
   695      * @see        java.lang.SecurityException
   694      * @see        java.lang.SecurityException
   696      * @see        java.lang.SecurityManager#checkPropertiesAccess()
   695      * @see        java.lang.SecurityManager#checkPropertiesAccess()
   697      * @see        java.util.Properties
   696      * @see        java.util.Properties
   698      */
   697      */
   721     }
   720     }
   722 
   721 
   723     private static String lineSeparator;
   722     private static String lineSeparator;
   724 
   723 
   725     /**
   724     /**
   726      * Sets the system properties to the <code>Properties</code>
   725      * Sets the system properties to the {@code Properties} argument.
   727      * argument.
   726      *
   728      * <p>
       
   729      * First, if there is a security manager, its
   727      * First, if there is a security manager, its
   730      * <code>checkPropertiesAccess</code> method is called with no
   728      * {@code checkPropertiesAccess} method is called with no
   731      * arguments. This may result in a security exception.
   729      * arguments. This may result in a security exception.
   732      * <p>
   730      * <p>
   733      * The argument becomes the current set of system properties for use
   731      * The argument becomes the current set of system properties for use
   734      * by the {@link #getProperty(String)} method. If the argument is
   732      * by the {@link #getProperty(String)} method. If the argument is
   735      * <code>null</code>, then the current set of system properties is
   733      * {@code null}, then the current set of system properties is
   736      * forgotten.
   734      * forgotten.
   737      *
   735      *
   738      * @param      props   the new system properties.
   736      * @param      props   the new system properties.
   739      * @exception  SecurityException  if a security manager exists and its
   737      * @throws     SecurityException  if a security manager exists and its
   740      *             <code>checkPropertiesAccess</code> method doesn't allow access
   738      *             {@code checkPropertiesAccess} method doesn't allow access
   741      *              to the system properties.
   739      *             to the system properties.
   742      * @see        #getProperties
   740      * @see        #getProperties
   743      * @see        java.util.Properties
   741      * @see        java.util.Properties
   744      * @see        java.lang.SecurityException
   742      * @see        java.lang.SecurityException
   745      * @see        java.lang.SecurityManager#checkPropertiesAccess()
   743      * @see        java.lang.SecurityManager#checkPropertiesAccess()
   746      */
   744      */
   756         System.props = props;
   754         System.props = props;
   757     }
   755     }
   758 
   756 
   759     /**
   757     /**
   760      * Gets the system property indicated by the specified key.
   758      * Gets the system property indicated by the specified key.
   761      * <p>
   759      *
   762      * First, if there is a security manager, its
   760      * First, if there is a security manager, its
   763      * <code>checkPropertyAccess</code> method is called with the key as
   761      * {@code checkPropertyAccess} method is called with the key as
   764      * its argument. This may result in a SecurityException.
   762      * its argument. This may result in a SecurityException.
   765      * <p>
   763      * <p>
   766      * If there is no current set of system properties, a set of system
   764      * If there is no current set of system properties, a set of system
   767      * properties is first created and initialized in the same manner as
   765      * properties is first created and initialized in the same manner as
   768      * for the <code>getProperties</code> method.
   766      * for the {@code getProperties} method.
   769      *
   767      *
   770      * @param      key   the name of the system property.
   768      * @param      key   the name of the system property.
   771      * @return     the string value of the system property,
   769      * @return     the string value of the system property,
   772      *             or <code>null</code> if there is no property with that key.
   770      *             or {@code null} if there is no property with that key.
   773      *
   771      *
   774      * @exception  SecurityException  if a security manager exists and its
   772      * @throws     SecurityException  if a security manager exists and its
   775      *             <code>checkPropertyAccess</code> method doesn't allow
   773      *             {@code checkPropertyAccess} method doesn't allow
   776      *              access to the specified system property.
   774      *             access to the specified system property.
   777      * @exception  NullPointerException if <code>key</code> is
   775      * @throws     NullPointerException if {@code key} is {@code null}.
   778      *             <code>null</code>.
   776      * @throws     IllegalArgumentException if {@code key} is empty.
   779      * @exception  IllegalArgumentException if <code>key</code> is empty.
       
   780      * @see        #setProperty
   777      * @see        #setProperty
   781      * @see        java.lang.SecurityException
   778      * @see        java.lang.SecurityException
   782      * @see        java.lang.SecurityManager#checkPropertyAccess(java.lang.String)
   779      * @see        java.lang.SecurityManager#checkPropertyAccess(java.lang.String)
   783      * @see        java.lang.System#getProperties()
   780      * @see        java.lang.System#getProperties()
   784      */
   781      */
   792         return props.getProperty(key);
   789         return props.getProperty(key);
   793     }
   790     }
   794 
   791 
   795     /**
   792     /**
   796      * Gets the system property indicated by the specified key.
   793      * Gets the system property indicated by the specified key.
   797      * <p>
   794      *
   798      * First, if there is a security manager, its
   795      * First, if there is a security manager, its
   799      * <code>checkPropertyAccess</code> method is called with the
   796      * {@code checkPropertyAccess} method is called with the
   800      * <code>key</code> as its argument.
   797      * {@code key} as its argument.
   801      * <p>
   798      * <p>
   802      * If there is no current set of system properties, a set of system
   799      * If there is no current set of system properties, a set of system
   803      * properties is first created and initialized in the same manner as
   800      * properties is first created and initialized in the same manner as
   804      * for the <code>getProperties</code> method.
   801      * for the {@code getProperties} method.
   805      *
   802      *
   806      * @param      key   the name of the system property.
   803      * @param      key   the name of the system property.
   807      * @param      def   a default value.
   804      * @param      def   a default value.
   808      * @return     the string value of the system property,
   805      * @return     the string value of the system property,
   809      *             or the default value if there is no property with that key.
   806      *             or the default value if there is no property with that key.
   810      *
   807      *
   811      * @exception  SecurityException  if a security manager exists and its
   808      * @throws     SecurityException  if a security manager exists and its
   812      *             <code>checkPropertyAccess</code> method doesn't allow
   809      *             {@code checkPropertyAccess} method doesn't allow
   813      *             access to the specified system property.
   810      *             access to the specified system property.
   814      * @exception  NullPointerException if <code>key</code> is
   811      * @throws     NullPointerException if {@code key} is {@code null}.
   815      *             <code>null</code>.
   812      * @throws     IllegalArgumentException if {@code key} is empty.
   816      * @exception  IllegalArgumentException if <code>key</code> is empty.
       
   817      * @see        #setProperty
   813      * @see        #setProperty
   818      * @see        java.lang.SecurityManager#checkPropertyAccess(java.lang.String)
   814      * @see        java.lang.SecurityManager#checkPropertyAccess(java.lang.String)
   819      * @see        java.lang.System#getProperties()
   815      * @see        java.lang.System#getProperties()
   820      */
   816      */
   821     public static String getProperty(String key, String def) {
   817     public static String getProperty(String key, String def) {
   828         return props.getProperty(key, def);
   824         return props.getProperty(key, def);
   829     }
   825     }
   830 
   826 
   831     /**
   827     /**
   832      * Sets the system property indicated by the specified key.
   828      * Sets the system property indicated by the specified key.
   833      * <p>
   829      *
   834      * First, if a security manager exists, its
   830      * First, if a security manager exists, its
   835      * <code>SecurityManager.checkPermission</code> method
   831      * {@code SecurityManager.checkPermission} method
   836      * is called with a <code>PropertyPermission(key, "write")</code>
   832      * is called with a {@code PropertyPermission(key, "write")}
   837      * permission. This may result in a SecurityException being thrown.
   833      * permission. This may result in a SecurityException being thrown.
   838      * If no exception is thrown, the specified property is set to the given
   834      * If no exception is thrown, the specified property is set to the given
   839      * value.
   835      * value.
   840      *
   836      *
   841      * @param      key   the name of the system property.
   837      * @param      key   the name of the system property.
   842      * @param      value the value of the system property.
   838      * @param      value the value of the system property.
   843      * @return     the previous value of the system property,
   839      * @return     the previous value of the system property,
   844      *             or <code>null</code> if it did not have one.
   840      *             or {@code null} if it did not have one.
   845      *
   841      *
   846      * @exception  SecurityException  if a security manager exists and its
   842      * @throws     SecurityException  if a security manager exists and its
   847      *             <code>checkPermission</code> method doesn't allow
   843      *             {@code checkPermission} method doesn't allow
   848      *             setting of the specified property.
   844      *             setting of the specified property.
   849      * @exception  NullPointerException if <code>key</code> or
   845      * @throws     NullPointerException if {@code key} or
   850      *             <code>value</code> is <code>null</code>.
   846      *             {@code value} is {@code null}.
   851      * @exception  IllegalArgumentException if <code>key</code> is empty.
   847      * @throws     IllegalArgumentException if {@code key} is empty.
   852      * @see        #getProperty
   848      * @see        #getProperty
   853      * @see        java.lang.System#getProperty(java.lang.String)
   849      * @see        java.lang.System#getProperty(java.lang.String)
   854      * @see        java.lang.System#getProperty(java.lang.String, java.lang.String)
   850      * @see        java.lang.System#getProperty(java.lang.String, java.lang.String)
   855      * @see        java.util.PropertyPermission
   851      * @see        java.util.PropertyPermission
   856      * @see        SecurityManager#checkPermission
   852      * @see        SecurityManager#checkPermission
   867         return (String) props.setProperty(key, value);
   863         return (String) props.setProperty(key, value);
   868     }
   864     }
   869 
   865 
   870     /**
   866     /**
   871      * Removes the system property indicated by the specified key.
   867      * Removes the system property indicated by the specified key.
   872      * <p>
   868      *
   873      * First, if a security manager exists, its
   869      * First, if a security manager exists, its
   874      * <code>SecurityManager.checkPermission</code> method
   870      * {@code SecurityManager.checkPermission} method
   875      * is called with a <code>PropertyPermission(key, "write")</code>
   871      * is called with a {@code PropertyPermission(key, "write")}
   876      * permission. This may result in a SecurityException being thrown.
   872      * permission. This may result in a SecurityException being thrown.
   877      * If no exception is thrown, the specified property is removed.
   873      * If no exception is thrown, the specified property is removed.
   878      *
   874      *
   879      * @param      key   the name of the system property to be removed.
   875      * @param      key   the name of the system property to be removed.
   880      * @return     the previous string value of the system property,
   876      * @return     the previous string value of the system property,
   881      *             or <code>null</code> if there was no property with that key.
   877      *             or {@code null} if there was no property with that key.
   882      *
   878      *
   883      * @exception  SecurityException  if a security manager exists and its
   879      * @throws     SecurityException  if a security manager exists and its
   884      *             <code>checkPropertyAccess</code> method doesn't allow
   880      *             {@code checkPropertyAccess} method doesn't allow
   885      *              access to the specified system property.
   881      *              access to the specified system property.
   886      * @exception  NullPointerException if <code>key</code> is
   882      * @throws     NullPointerException if {@code key} is {@code null}.
   887      *             <code>null</code>.
   883      * @throws     IllegalArgumentException if {@code key} is empty.
   888      * @exception  IllegalArgumentException if <code>key</code> is empty.
       
   889      * @see        #getProperty
   884      * @see        #getProperty
   890      * @see        #setProperty
   885      * @see        #setProperty
   891      * @see        java.util.Properties
   886      * @see        java.util.Properties
   892      * @see        java.lang.SecurityException
   887      * @see        java.lang.SecurityException
   893      * @see        java.lang.SecurityManager#checkPropertiesAccess()
   888      * @see        java.lang.SecurityManager#checkPropertiesAccess()
   918      * value.
   913      * value.
   919      *
   914      *
   920      * <p>If a security manager exists, its
   915      * <p>If a security manager exists, its
   921      * {@link SecurityManager#checkPermission checkPermission}
   916      * {@link SecurityManager#checkPermission checkPermission}
   922      * method is called with a
   917      * method is called with a
   923      * <code>{@link RuntimePermission}("getenv."+name)</code>
   918      * {@code {@link RuntimePermission}("getenv."+name)}
   924      * permission.  This may result in a {@link SecurityException}
   919      * permission.  This may result in a {@link SecurityException}
   925      * being thrown.  If no exception is thrown the value of the
   920      * being thrown.  If no exception is thrown the value of the
   926      * variable <code>name</code> is returned.
   921      * variable {@code name} is returned.
   927      *
   922      *
   928      * <p><a id="EnvironmentVSSystemProperties"><i>System
   923      * <p><a id="EnvironmentVSSystemProperties"><i>System
   929      * properties</i> and <i>environment variables</i></a> are both
   924      * properties</i> and <i>environment variables</i></a> are both
   930      * conceptually mappings between names and values.  Both
   925      * conceptually mappings between names and values.  Both
   931      * mechanisms can be used to pass user-defined information to a
   926      * mechanisms can be used to pass user-defined information to a
   936      * insensitivity, on different operating systems.  For these
   931      * insensitivity, on different operating systems.  For these
   937      * reasons, environment variables are more likely to have
   932      * reasons, environment variables are more likely to have
   938      * unintended side effects.  It is best to use system properties
   933      * unintended side effects.  It is best to use system properties
   939      * where possible.  Environment variables should be used when a
   934      * where possible.  Environment variables should be used when a
   940      * global effect is desired, or when an external system interface
   935      * global effect is desired, or when an external system interface
   941      * requires an environment variable (such as <code>PATH</code>).
   936      * requires an environment variable (such as {@code PATH}).
   942      *
   937      *
   943      * <p>On UNIX systems the alphabetic case of <code>name</code> is
   938      * <p>On UNIX systems the alphabetic case of {@code name} is
   944      * typically significant, while on Microsoft Windows systems it is
   939      * typically significant, while on Microsoft Windows systems it is
   945      * typically not.  For example, the expression
   940      * typically not.  For example, the expression
   946      * <code>System.getenv("FOO").equals(System.getenv("foo"))</code>
   941      * {@code System.getenv("FOO").equals(System.getenv("foo"))}
   947      * is likely to be true on Microsoft Windows.
   942      * is likely to be true on Microsoft Windows.
   948      *
   943      *
   949      * @param  name the name of the environment variable
   944      * @param  name the name of the environment variable
   950      * @return the string value of the variable, or <code>null</code>
   945      * @return the string value of the variable, or {@code null}
   951      *         if the variable is not defined in the system environment
   946      *         if the variable is not defined in the system environment
   952      * @throws NullPointerException if <code>name</code> is <code>null</code>
   947      * @throws NullPointerException if {@code name} is {@code null}
   953      * @throws SecurityException
   948      * @throws SecurityException
   954      *         if a security manager exists and its
   949      *         if a security manager exists and its
   955      *         {@link SecurityManager#checkPermission checkPermission}
   950      *         {@link SecurityManager#checkPermission checkPermission}
   956      *         method doesn't allow access to the environment variable
   951      *         method doesn't allow access to the environment variable
   957      *         <code>name</code>
   952      *         {@code name}
   958      * @see    #getenv()
   953      * @see    #getenv()
   959      * @see    ProcessBuilder#environment()
   954      * @see    ProcessBuilder#environment()
   960      */
   955      */
   961     public static String getenv(String name) {
   956     public static String getenv(String name) {
   962         SecurityManager sm = getSecurityManager();
   957         SecurityManager sm = getSecurityManager();
   989      * <p>The returned map is typically case-sensitive on all platforms.
   984      * <p>The returned map is typically case-sensitive on all platforms.
   990      *
   985      *
   991      * <p>If a security manager exists, its
   986      * <p>If a security manager exists, its
   992      * {@link SecurityManager#checkPermission checkPermission}
   987      * {@link SecurityManager#checkPermission checkPermission}
   993      * method is called with a
   988      * method is called with a
   994      * <code>{@link RuntimePermission}("getenv.*")</code>
   989      * {@code {@link RuntimePermission}("getenv.*")} permission.
   995      * permission.  This may result in a {@link SecurityException} being
   990      * This may result in a {@link SecurityException} being thrown.
   996      * thrown.
       
   997      *
   991      *
   998      * <p>When passing information to a Java subprocess,
   992      * <p>When passing information to a Java subprocess,
   999      * <a href=#EnvironmentVSSystemProperties>system properties</a>
   993      * <a href=#EnvironmentVSSystemProperties>system properties</a>
  1000      * are generally preferred over environment variables.
   994      * are generally preferred over environment variables.
  1001      *
   995      *
  1019 
  1013 
  1020     /**
  1014     /**
  1021      * {@code System.Logger} instances log messages that will be
  1015      * {@code System.Logger} instances log messages that will be
  1022      * routed to the underlying logging framework the {@link System.LoggerFinder
  1016      * routed to the underlying logging framework the {@link System.LoggerFinder
  1023      * LoggerFinder} uses.
  1017      * LoggerFinder} uses.
  1024      * <p>
  1018      *
  1025      * {@code System.Logger} instances are typically obtained from
  1019      * {@code System.Logger} instances are typically obtained from
  1026      * the {@link java.lang.System System} class, by calling
  1020      * the {@link java.lang.System System} class, by calling
  1027      * {@link java.lang.System#getLogger(java.lang.String) System.getLogger(loggerName)}
  1021      * {@link java.lang.System#getLogger(java.lang.String) System.getLogger(loggerName)}
  1028      * or {@link java.lang.System#getLogger(java.lang.String, java.util.ResourceBundle)
  1022      * or {@link java.lang.System#getLogger(java.lang.String, java.util.ResourceBundle)
  1029      * System.getLogger(loggerName, bundle)}.
  1023      * System.getLogger(loggerName, bundle)}.
  1031      * @see java.lang.System#getLogger(java.lang.String)
  1025      * @see java.lang.System#getLogger(java.lang.String)
  1032      * @see java.lang.System#getLogger(java.lang.String, java.util.ResourceBundle)
  1026      * @see java.lang.System#getLogger(java.lang.String, java.util.ResourceBundle)
  1033      * @see java.lang.System.LoggerFinder
  1027      * @see java.lang.System.LoggerFinder
  1034      *
  1028      *
  1035      * @since 9
  1029      * @since 9
  1036      *
       
  1037      */
  1030      */
  1038     public interface Logger {
  1031     public interface Logger {
  1039 
  1032 
  1040         /**
  1033         /**
  1041          * System {@linkplain Logger loggers} levels.
  1034          * System {@linkplain Logger loggers} levels.
  1042          * <p>
  1035          *
  1043          * A level has a {@linkplain #getName() name} and {@linkplain
  1036          * A level has a {@linkplain #getName() name} and {@linkplain
  1044          * #getSeverity() severity}.
  1037          * #getSeverity() severity}.
  1045          * Level values are {@link #ALL}, {@link #TRACE}, {@link #DEBUG},
  1038          * Level values are {@link #ALL}, {@link #TRACE}, {@link #DEBUG},
  1046          * {@link #INFO}, {@link #WARNING}, {@link #ERROR}, {@link #OFF},
  1039          * {@link #INFO}, {@link #WARNING}, {@link #ERROR}, {@link #OFF},
  1047          * by order of increasing severity.
  1040          * by order of increasing severity.
  1197             log(level, (ResourceBundle) null, msg, (Object[]) null);
  1190             log(level, (ResourceBundle) null, msg, (Object[]) null);
  1198         }
  1191         }
  1199 
  1192 
  1200         /**
  1193         /**
  1201          * Logs a lazily supplied message.
  1194          * Logs a lazily supplied message.
  1202          * <p>
  1195          *
  1203          * If the logger is currently enabled for the given log message level
  1196          * If the logger is currently enabled for the given log message level
  1204          * then a message is logged that is the result produced by the
  1197          * then a message is logged that is the result produced by the
  1205          * given supplier function.  Otherwise, the supplier is not operated on.
  1198          * given supplier function.  Otherwise, the supplier is not operated on.
  1206          *
  1199          *
  1207          * @implSpec When logging is enabled for the given level, the default
  1200          * @implSpec When logging is enabled for the given level, the default
  1221             }
  1214             }
  1222         }
  1215         }
  1223 
  1216 
  1224         /**
  1217         /**
  1225          * Logs a message produced from the given object.
  1218          * Logs a message produced from the given object.
  1226          * <p>
  1219          *
  1227          * If the logger is currently enabled for the given log message level then
  1220          * If the logger is currently enabled for the given log message level then
  1228          * a message is logged that, by default, is the result produced from
  1221          * a message is logged that, by default, is the result produced from
  1229          * calling  toString on the given object.
  1222          * calling  toString on the given object.
  1230          * Otherwise, the object is not operated on.
  1223          * Otherwise, the object is not operated on.
  1231          *
  1224          *
  1267             this.log(level, null, msg, thrown);
  1260             this.log(level, null, msg, thrown);
  1268         }
  1261         }
  1269 
  1262 
  1270         /**
  1263         /**
  1271          * Logs a lazily supplied message associated with a given throwable.
  1264          * Logs a lazily supplied message associated with a given throwable.
  1272          * <p>
  1265          *
  1273          * If the logger is currently enabled for the given log message level
  1266          * If the logger is currently enabled for the given log message level
  1274          * then a message is logged that is the result produced by the
  1267          * then a message is logged that is the result produced by the
  1275          * given supplier function.  Otherwise, the supplier is not operated on.
  1268          * given supplier function.  Otherwise, the supplier is not operated on.
  1276          *
  1269          *
  1277          * @implSpec When logging is enabled for the given level, the default
  1270          * @implSpec When logging is enabled for the given level, the default
  1316             this.log(level, null, format, params);
  1309             this.log(level, null, format, params);
  1317         }
  1310         }
  1318 
  1311 
  1319         /**
  1312         /**
  1320          * Logs a localized message associated with a given throwable.
  1313          * Logs a localized message associated with a given throwable.
  1321          * <p>
  1314          *
  1322          * If the given resource bundle is non-{@code null},  the {@code msg}
  1315          * If the given resource bundle is non-{@code null},  the {@code msg}
  1323          * string is localized using the given resource bundle.
  1316          * string is localized using the given resource bundle.
  1324          * Otherwise the {@code msg} string is not localized.
  1317          * Otherwise the {@code msg} string is not localized.
  1325          *
  1318          *
  1326          * @param level the log message level.
  1319          * @param level the log message level.
  1337                 Throwable thrown);
  1330                 Throwable thrown);
  1338 
  1331 
  1339         /**
  1332         /**
  1340          * Logs a message with resource bundle and an optional list of
  1333          * Logs a message with resource bundle and an optional list of
  1341          * parameters.
  1334          * parameters.
  1342          * <p>
  1335          *
  1343          * If the given resource bundle is non-{@code null},  the {@code format}
  1336          * If the given resource bundle is non-{@code null},  the {@code format}
  1344          * string is localized using the given resource bundle.
  1337          * string is localized using the given resource bundle.
  1345          * Otherwise the {@code format} string is not localized.
  1338          * Otherwise the {@code format} string is not localized.
  1346          *
  1339          *
  1347          * @param level the log message level.
  1340          * @param level the log message level.
  1355          *
  1348          *
  1356          * @throws NullPointerException if {@code level} is {@code null}.
  1349          * @throws NullPointerException if {@code level} is {@code null}.
  1357          */
  1350          */
  1358         public void log(Level level, ResourceBundle bundle, String format,
  1351         public void log(Level level, ResourceBundle bundle, String format,
  1359                 Object... params);
  1352                 Object... params);
  1360 
       
  1361 
       
  1362     }
  1353     }
  1363 
  1354 
  1364     /**
  1355     /**
  1365      * The {@code LoggerFinder} service is responsible for creating, managing,
  1356      * The {@code LoggerFinder} service is responsible for creating, managing,
  1366      * and configuring loggers to the underlying framework it uses.
  1357      * and configuring loggers to the underlying framework it uses.
  1367      * <p>
  1358      *
  1368      * A logger finder is a concrete implementation of this class that has a
  1359      * A logger finder is a concrete implementation of this class that has a
  1369      * zero-argument constructor and implements the abstract methods defined
  1360      * zero-argument constructor and implements the abstract methods defined
  1370      * by this class.
  1361      * by this class.
  1371      * The loggers returned from a logger finder are capable of routing log
  1362      * The loggers returned from a logger finder are capable of routing log
  1372      * messages to the logging backend this provider supports.
  1363      * messages to the logging backend this provider supports.
  1514          * this.getLogger(name, module)} to obtain a logger, then wraps that
  1505          * this.getLogger(name, module)} to obtain a logger, then wraps that
  1515          * logger in a {@link Logger} instance where all methods that do not
  1506          * logger in a {@link Logger} instance where all methods that do not
  1516          * take a {@link ResourceBundle} as parameter are redirected to one
  1507          * take a {@link ResourceBundle} as parameter are redirected to one
  1517          * which does - passing the given {@code bundle} for
  1508          * which does - passing the given {@code bundle} for
  1518          * localization. So for instance, a call to {@link
  1509          * localization. So for instance, a call to {@link
  1519          * Logger#log(Level, String) Logger.log(Level.INFO, msg)}
  1510          * Logger#log(Logger.Level, String) Logger.log(Level.INFO, msg)}
  1520          * will end up as a call to {@link
  1511          * will end up as a call to {@link
  1521          * Logger#log(Level, ResourceBundle, String, Object...)
  1512          * Logger#log(Logger.Level, ResourceBundle, String, Object...)
  1522          * Logger.log(Level.INFO, bundle, msg, (Object[])null)} on the wrapped
  1513          * Logger.log(Level.INFO, bundle, msg, (Object[])null)} on the wrapped
  1523          * logger instance.
  1514          * logger instance.
  1524          * Note however that by default, string messages returned by {@link
  1515          * Note however that by default, string messages returned by {@link
  1525          * java.util.function.Supplier Supplier&lt;String&gt;} will not be
  1516          * java.util.function.Supplier Supplier&lt;String&gt;} will not be
  1526          * localized, as it is assumed that such strings are messages which are
  1517          * localized, as it is assumed that such strings are messages which are
  1700     /**
  1691     /**
  1701      * Terminates the currently running Java Virtual Machine. The
  1692      * Terminates the currently running Java Virtual Machine. The
  1702      * argument serves as a status code; by convention, a nonzero status
  1693      * argument serves as a status code; by convention, a nonzero status
  1703      * code indicates abnormal termination.
  1694      * code indicates abnormal termination.
  1704      * <p>
  1695      * <p>
  1705      * This method calls the <code>exit</code> method in class
  1696      * This method calls the {@code exit} method in class
  1706      * <code>Runtime</code>. This method never returns normally.
  1697      * {@code Runtime}. This method never returns normally.
  1707      * <p>
  1698      * <p>
  1708      * The call <code>System.exit(n)</code> is effectively equivalent to
  1699      * The call {@code System.exit(n)} is effectively equivalent to
  1709      * the call:
  1700      * the call:
  1710      * <blockquote><pre>
  1701      * <blockquote><pre>
  1711      * Runtime.getRuntime().exit(n)
  1702      * Runtime.getRuntime().exit(n)
  1712      * </pre></blockquote>
  1703      * </pre></blockquote>
  1713      *
  1704      *
  1714      * @param      status   exit status.
  1705      * @param      status   exit status.
  1715      * @throws  SecurityException
  1706      * @throws  SecurityException
  1716      *        if a security manager exists and its <code>checkExit</code>
  1707      *        if a security manager exists and its {@code checkExit}
  1717      *        method doesn't allow exit with the specified status.
  1708      *        method doesn't allow exit with the specified status.
  1718      * @see        java.lang.Runtime#exit(int)
  1709      * @see        java.lang.Runtime#exit(int)
  1719      */
  1710      */
  1720     public static void exit(int status) {
  1711     public static void exit(int status) {
  1721         Runtime.getRuntime().exit(status);
  1712         Runtime.getRuntime().exit(status);
  1722     }
  1713     }
  1723 
  1714 
  1724     /**
  1715     /**
  1725      * Runs the garbage collector.
  1716      * Runs the garbage collector.
  1726      * <p>
  1717      *
  1727      * Calling the <code>gc</code> method suggests that the Java Virtual
  1718      * Calling the {@code gc} method suggests that the Java Virtual
  1728      * Machine expend effort toward recycling unused objects in order to
  1719      * Machine expend effort toward recycling unused objects in order to
  1729      * make the memory they currently occupy available for quick reuse.
  1720      * make the memory they currently occupy available for quick reuse.
  1730      * When control returns from the method call, the Java Virtual
  1721      * When control returns from the method call, the Java Virtual
  1731      * Machine has made a best effort to reclaim space from all discarded
  1722      * Machine has made a best effort to reclaim space from all discarded
  1732      * objects.
  1723      * objects.
  1733      * <p>
  1724      * <p>
  1734      * The call <code>System.gc()</code> is effectively equivalent to the
  1725      * The call {@code System.gc()} is effectively equivalent to the
  1735      * call:
  1726      * call:
  1736      * <blockquote><pre>
  1727      * <blockquote><pre>
  1737      * Runtime.getRuntime().gc()
  1728      * Runtime.getRuntime().gc()
  1738      * </pre></blockquote>
  1729      * </pre></blockquote>
  1739      *
  1730      *
  1743         Runtime.getRuntime().gc();
  1734         Runtime.getRuntime().gc();
  1744     }
  1735     }
  1745 
  1736 
  1746     /**
  1737     /**
  1747      * Runs the finalization methods of any objects pending finalization.
  1738      * Runs the finalization methods of any objects pending finalization.
  1748      * <p>
  1739      *
  1749      * Calling this method suggests that the Java Virtual Machine expend
  1740      * Calling this method suggests that the Java Virtual Machine expend
  1750      * effort toward running the <code>finalize</code> methods of objects
  1741      * effort toward running the {@code finalize} methods of objects
  1751      * that have been found to be discarded but whose <code>finalize</code>
  1742      * that have been found to be discarded but whose {@code finalize}
  1752      * methods have not yet been run. When control returns from the
  1743      * methods have not yet been run. When control returns from the
  1753      * method call, the Java Virtual Machine has made a best effort to
  1744      * method call, the Java Virtual Machine has made a best effort to
  1754      * complete all outstanding finalizations.
  1745      * complete all outstanding finalizations.
  1755      * <p>
  1746      * <p>
  1756      * The call <code>System.runFinalization()</code> is effectively
  1747      * The call {@code System.runFinalization()} is effectively
  1757      * equivalent to the call:
  1748      * equivalent to the call:
  1758      * <blockquote><pre>
  1749      * <blockquote><pre>
  1759      * Runtime.getRuntime().runFinalization()
  1750      * Runtime.getRuntime().runFinalization()
  1760      * </pre></blockquote>
  1751      * </pre></blockquote>
  1761      *
  1752      *
  1781      *
  1772      *
  1782      * Otherwise, the filename argument is mapped to a native library image in
  1773      * Otherwise, the filename argument is mapped to a native library image in
  1783      * an implementation-dependent manner.
  1774      * an implementation-dependent manner.
  1784      *
  1775      *
  1785      * <p>
  1776      * <p>
  1786      * The call <code>System.load(name)</code> is effectively equivalent
  1777      * The call {@code System.load(name)} is effectively equivalent
  1787      * to the call:
  1778      * to the call:
  1788      * <blockquote><pre>
  1779      * <blockquote><pre>
  1789      * Runtime.getRuntime().load(name)
  1780      * Runtime.getRuntime().load(name)
  1790      * </pre></blockquote>
  1781      * </pre></blockquote>
  1791      *
  1782      *
  1792      * @param      filename   the file to load.
  1783      * @param      filename   the file to load.
  1793      * @exception  SecurityException  if a security manager exists and its
  1784      * @throws     SecurityException  if a security manager exists and its
  1794      *             <code>checkLink</code> method doesn't allow
  1785      *             {@code checkLink} method doesn't allow
  1795      *             loading of the specified dynamic library
  1786      *             loading of the specified dynamic library
  1796      * @exception  UnsatisfiedLinkError  if either the filename is not an
  1787      * @throws     UnsatisfiedLinkError  if either the filename is not an
  1797      *             absolute path name, the native library is not statically
  1788      *             absolute path name, the native library is not statically
  1798      *             linked with the VM, or the library cannot be mapped to
  1789      *             linked with the VM, or the library cannot be mapped to
  1799      *             a native library image by the host system.
  1790      *             a native library image by the host system.
  1800      * @exception  NullPointerException if <code>filename</code> is
  1791      * @throws     NullPointerException if {@code filename} is {@code null}
  1801      *             <code>null</code>
       
  1802      * @see        java.lang.Runtime#load(java.lang.String)
  1792      * @see        java.lang.Runtime#load(java.lang.String)
  1803      * @see        java.lang.SecurityManager#checkLink(java.lang.String)
  1793      * @see        java.lang.SecurityManager#checkLink(java.lang.String)
  1804      */
  1794      */
  1805     @CallerSensitive
  1795     @CallerSensitive
  1806     public static void load(String filename) {
  1796     public static void load(String filename) {
  1807         Runtime.getRuntime().load0(Reflection.getCallerClass(), filename);
  1797         Runtime.getRuntime().load0(Reflection.getCallerClass(), filename);
  1808     }
  1798     }
  1809 
  1799 
  1810     /**
  1800     /**
  1811      * Loads the native library specified by the <code>libname</code>
  1801      * Loads the native library specified by the {@code libname}
  1812      * argument.  The <code>libname</code> argument must not contain any platform
  1802      * argument.  The {@code libname} argument must not contain any platform
  1813      * specific prefix, file extension or path. If a native library
  1803      * specific prefix, file extension or path. If a native library
  1814      * called <code>libname</code> is statically linked with the VM, then the
  1804      * called {@code libname} is statically linked with the VM, then the
  1815      * JNI_OnLoad_<code>libname</code> function exported by the library is invoked.
  1805      * JNI_OnLoad_{@code libname} function exported by the library is invoked.
  1816      * See the <a href="{@docRoot}/../specs/jni/index.html"> JNI Specification</a>
  1806      * See the <a href="{@docRoot}/../specs/jni/index.html"> JNI Specification</a>
  1817      * for more details.
  1807      * for more details.
  1818      *
  1808      *
  1819      * Otherwise, the libname argument is loaded from a system library
  1809      * Otherwise, the libname argument is loaded from a system library
  1820      * location and mapped to a native library image in an implementation-
  1810      * location and mapped to a native library image in an implementation-
  1821      * dependent manner.
  1811      * dependent manner.
  1822      * <p>
  1812      * <p>
  1823      * The call <code>System.loadLibrary(name)</code> is effectively
  1813      * The call {@code System.loadLibrary(name)} is effectively
  1824      * equivalent to the call
  1814      * equivalent to the call
  1825      * <blockquote><pre>
  1815      * <blockquote><pre>
  1826      * Runtime.getRuntime().loadLibrary(name)
  1816      * Runtime.getRuntime().loadLibrary(name)
  1827      * </pre></blockquote>
  1817      * </pre></blockquote>
  1828      *
  1818      *
  1829      * @param      libname   the name of the library.
  1819      * @param      libname   the name of the library.
  1830      * @exception  SecurityException  if a security manager exists and its
  1820      * @throws     SecurityException  if a security manager exists and its
  1831      *             <code>checkLink</code> method doesn't allow
  1821      *             {@code checkLink} method doesn't allow
  1832      *             loading of the specified dynamic library
  1822      *             loading of the specified dynamic library
  1833      * @exception  UnsatisfiedLinkError if either the libname argument
  1823      * @throws     UnsatisfiedLinkError if either the libname argument
  1834      *             contains a file path, the native library is not statically
  1824      *             contains a file path, the native library is not statically
  1835      *             linked with the VM,  or the library cannot be mapped to a
  1825      *             linked with the VM,  or the library cannot be mapped to a
  1836      *             native library image by the host system.
  1826      *             native library image by the host system.
  1837      * @exception  NullPointerException if <code>libname</code> is
  1827      * @throws     NullPointerException if {@code libname} is {@code null}
  1838      *             <code>null</code>
       
  1839      * @see        java.lang.Runtime#loadLibrary(java.lang.String)
  1828      * @see        java.lang.Runtime#loadLibrary(java.lang.String)
  1840      * @see        java.lang.SecurityManager#checkLink(java.lang.String)
  1829      * @see        java.lang.SecurityManager#checkLink(java.lang.String)
  1841      */
  1830      */
  1842     @CallerSensitive
  1831     @CallerSensitive
  1843     public static void loadLibrary(String libname) {
  1832     public static void loadLibrary(String libname) {
  1848      * Maps a library name into a platform-specific string representing
  1837      * Maps a library name into a platform-specific string representing
  1849      * a native library.
  1838      * a native library.
  1850      *
  1839      *
  1851      * @param      libname the name of the library.
  1840      * @param      libname the name of the library.
  1852      * @return     a platform-dependent native library name.
  1841      * @return     a platform-dependent native library name.
  1853      * @exception  NullPointerException if <code>libname</code> is
  1842      * @throws     NullPointerException if {@code libname} is {@code null}
  1854      *             <code>null</code>
       
  1855      * @see        java.lang.System#loadLibrary(java.lang.String)
  1843      * @see        java.lang.System#loadLibrary(java.lang.String)
  1856      * @see        java.lang.ClassLoader#findLibrary(java.lang.String)
  1844      * @see        java.lang.ClassLoader#findLibrary(java.lang.String)
  1857      * @since      1.2
  1845      * @since      1.2
  1858      */
  1846      */
  1859     public static native String mapLibraryName(String libname);
  1847     public static native String mapLibraryName(String libname);