< prev index next >

src/java.base/share/classes/java/lang/System.java

Print this page
rev 53037 : 8242154: Backport parts of JDK-4947890 to OpenJDK 11u


 755      * unless otherwise specified</strong>.
 756      * See {@linkplain #getProperties getProperties} for details.
 757      *
 758      * @param      props   the new system properties.
 759      * @throws     SecurityException  if a security manager exists and its
 760      *             {@code checkPropertiesAccess} method doesn't allow access
 761      *             to the system properties.
 762      * @see        #getProperties
 763      * @see        java.util.Properties
 764      * @see        java.lang.SecurityException
 765      * @see        java.lang.SecurityManager#checkPropertiesAccess()
 766      */
 767     public static void setProperties(Properties props) {
 768         SecurityManager sm = getSecurityManager();
 769         if (sm != null) {
 770             sm.checkPropertiesAccess();
 771         }
 772         if (props == null) {
 773             props = new Properties();
 774             initProperties(props);




 775         }
 776         System.props = props;
 777     }
 778 
 779     /**
 780      * Gets the system property indicated by the specified key.
 781      *
 782      * First, if there is a security manager, its
 783      * {@code checkPropertyAccess} method is called with the key as
 784      * its argument. This may result in a SecurityException.
 785      * <p>
 786      * If there is no current set of system properties, a set of system
 787      * properties is first created and initialized in the same manner as
 788      * for the {@code getProperties} method.
 789      *
 790      * @apiNote
 791      * <strong>Changing a standard system property may have unpredictable results
 792      * unless otherwise specified</strong>.
 793      * See {@linkplain #getProperties getProperties} for details.
 794      *
 795      * @param      key   the name of the system property.
 796      * @return     the string value of the system property,




 755      * unless otherwise specified</strong>.
 756      * See {@linkplain #getProperties getProperties} for details.
 757      *
 758      * @param      props   the new system properties.
 759      * @throws     SecurityException  if a security manager exists and its
 760      *             {@code checkPropertiesAccess} method doesn't allow access
 761      *             to the system properties.
 762      * @see        #getProperties
 763      * @see        java.util.Properties
 764      * @see        java.lang.SecurityException
 765      * @see        java.lang.SecurityManager#checkPropertiesAccess()
 766      */
 767     public static void setProperties(Properties props) {
 768         SecurityManager sm = getSecurityManager();
 769         if (sm != null) {
 770             sm.checkPropertiesAccess();
 771         }
 772         if (props == null) {
 773             props = new Properties();
 774             initProperties(props);
 775             System.props = props;
 776             VersionProps.init();
 777         } else {
 778             System.props = props;
 779         }

 780     }
 781 
 782     /**
 783      * Gets the system property indicated by the specified key.
 784      *
 785      * First, if there is a security manager, its
 786      * {@code checkPropertyAccess} method is called with the key as
 787      * its argument. This may result in a SecurityException.
 788      * <p>
 789      * If there is no current set of system properties, a set of system
 790      * properties is first created and initialized in the same manner as
 791      * for the {@code getProperties} method.
 792      *
 793      * @apiNote
 794      * <strong>Changing a standard system property may have unpredictable results
 795      * unless otherwise specified</strong>.
 796      * See {@linkplain #getProperties getProperties} for details.
 797      *
 798      * @param      key   the name of the system property.
 799      * @return     the string value of the system property,


< prev index next >