jdk/src/java.base/share/classes/sun/net/NetProperties.java
changeset 32649 2ee9017c7597
parent 27565 729f9700483a
equal deleted inserted replaced
32648:1fa861caf840 32649:2ee9017c7597
    37  * @author Jean-Christophe Collet
    37  * @author Jean-Christophe Collet
    38  *
    38  *
    39  */
    39  */
    40 
    40 
    41 public class NetProperties {
    41 public class NetProperties {
    42     static private Properties props = new Properties();
    42     private static Properties props = new Properties();
    43     static {
    43     static {
    44         AccessController.doPrivileged(
    44         AccessController.doPrivileged(
    45             new PrivilegedAction<Void>() {
    45             new PrivilegedAction<Void>() {
    46                 public Void run() {
    46                 public Void run() {
    47                     loadDefaultProperties();
    47                     loadDefaultProperties();
    54 
    54 
    55     /*
    55     /*
    56      * Loads the default networking system properties
    56      * Loads the default networking system properties
    57      * the file is in jre/lib/net.properties
    57      * the file is in jre/lib/net.properties
    58      */
    58      */
    59     static private void loadDefaultProperties() {
    59     private static void loadDefaultProperties() {
    60         String fname = System.getProperty("java.home");
    60         String fname = System.getProperty("java.home");
    61         if (fname == null) {
    61         if (fname == null) {
    62             throw new Error("Can't find java.home ??");
    62             throw new Error("Can't find java.home ??");
    63         }
    63         }
    64         try {
    64         try {
    84      *          <code>checkPropertiesAccess</code> method doesn't allow access
    84      *          <code>checkPropertiesAccess</code> method doesn't allow access
    85      *          to the system properties.
    85      *          to the system properties.
    86      * @return the <code>String</code> value for the property,
    86      * @return the <code>String</code> value for the property,
    87      *         or <code>null</code>
    87      *         or <code>null</code>
    88      */
    88      */
    89     static public String get(String key) {
    89     public static String get(String key) {
    90         String def = props.getProperty(key);
    90         String def = props.getProperty(key);
    91         try {
    91         try {
    92             return System.getProperty(key, def);
    92             return System.getProperty(key, def);
    93         } catch (IllegalArgumentException e) {
    93         } catch (IllegalArgumentException e) {
    94         } catch (NullPointerException e) {
    94         } catch (NullPointerException e) {
   106      *          <code>checkPropertiesAccess</code> method doesn't allow access
   106      *          <code>checkPropertiesAccess</code> method doesn't allow access
   107      *          to the system properties.
   107      *          to the system properties.
   108      * @return the <code>Integer</code> value for the property,
   108      * @return the <code>Integer</code> value for the property,
   109      *         or <code>null</code>
   109      *         or <code>null</code>
   110      */
   110      */
   111     static public Integer getInteger(String key, int defval) {
   111     public static Integer getInteger(String key, int defval) {
   112         String val = null;
   112         String val = null;
   113 
   113 
   114         try {
   114         try {
   115             val = System.getProperty(key, props.getProperty(key));
   115             val = System.getProperty(key, props.getProperty(key));
   116         } catch (IllegalArgumentException e) {
   116         } catch (IllegalArgumentException e) {
   135      *          <code>checkPropertiesAccess</code> method doesn't allow access
   135      *          <code>checkPropertiesAccess</code> method doesn't allow access
   136      *          to the system properties.
   136      *          to the system properties.
   137      * @return the <code>Boolean</code> value for the property,
   137      * @return the <code>Boolean</code> value for the property,
   138      *         or <code>null</code>
   138      *         or <code>null</code>
   139      */
   139      */
   140     static public Boolean getBoolean(String key) {
   140     public static Boolean getBoolean(String key) {
   141         String val = null;
   141         String val = null;
   142 
   142 
   143         try {
   143         try {
   144             val = System.getProperty(key, props.getProperty(key));
   144             val = System.getProperty(key, props.getProperty(key));
   145         } catch (IllegalArgumentException e) {
   145         } catch (IllegalArgumentException e) {