< prev index next >

src/java.base/share/classes/jdk/internal/misc/VM.java

Print this page
rev 52426 : 8185496: Improve performance of system properties initialization in initPhase1
8213424: VersionProps duplicate and skipped initialization


 182 
 183     // Save a private copy of the system properties and remove
 184     // the system properties that are not intended for public access.
 185     //
 186     // This method can only be invoked during system initialization.
 187     public static void saveAndRemoveProperties(Properties props) {
 188         if (initLevel() != 0)
 189             throw new IllegalStateException("Wrong init level");
 190 
 191         @SuppressWarnings({"rawtypes", "unchecked"})
 192         Map<String, String> sp =
 193             Map.ofEntries(props.entrySet().toArray(new Map.Entry[0]));
 194         // only main thread is running at this time, so savedProps and
 195         // its content will be correctly published to threads started later
 196         savedProps = sp;
 197 
 198         // Set the maximum amount of direct memory.  This value is controlled
 199         // by the vm option -XX:MaxDirectMemorySize=<size>.
 200         // The maximum amount of allocatable direct buffer memory (in bytes)
 201         // from the system property sun.nio.MaxDirectMemorySize set by the VM.

 202         // The system property will be removed.
 203         String s = (String)props.remove("sun.nio.MaxDirectMemorySize");
 204         if (s != null) {
 205             if (s.equals("-1")) {
 206                 // -XX:MaxDirectMemorySize not given, take default
 207                 directMemory = Runtime.getRuntime().maxMemory();
 208             } else {
 209                 long l = Long.parseLong(s);
 210                 if (l > -1)
 211                     directMemory = l;
 212             }
 213         }
 214 
 215         // Check if direct buffers should be page aligned
 216         s = (String)props.remove("sun.nio.PageAlignDirectMemory");
 217         if ("true".equals(s))
 218             pageAlignDirectMemory = true;
 219 
 220         // Remove other private system properties
 221         // used by java.lang.Integer.IntegerCache
 222         props.remove("java.lang.Integer.IntegerCache.high");
 223 
 224         // used by sun.launcher.LauncherHelper
 225         props.remove("sun.java.launcher.diag");
 226 
 227         // used by jdk.internal.loader.ClassLoaders
 228         props.remove("jdk.boot.class.path.append");
 229     }
 230 
 231     // Initialize any miscellaneous operating system settings that need to be
 232     // set for the class libraries.




 182 
 183     // Save a private copy of the system properties and remove
 184     // the system properties that are not intended for public access.
 185     //
 186     // This method can only be invoked during system initialization.
 187     public static void saveAndRemoveProperties(Properties props) {
 188         if (initLevel() != 0)
 189             throw new IllegalStateException("Wrong init level");
 190 
 191         @SuppressWarnings({"rawtypes", "unchecked"})
 192         Map<String, String> sp =
 193             Map.ofEntries(props.entrySet().toArray(new Map.Entry[0]));
 194         // only main thread is running at this time, so savedProps and
 195         // its content will be correctly published to threads started later
 196         savedProps = sp;
 197 
 198         // Set the maximum amount of direct memory.  This value is controlled
 199         // by the vm option -XX:MaxDirectMemorySize=<size>.
 200         // The maximum amount of allocatable direct buffer memory (in bytes)
 201         // from the system property sun.nio.MaxDirectMemorySize set by the VM.
 202         // If not set or set to -1, the max memory will be used
 203         // The system property will be removed.
 204         String s = (String)props.remove("sun.nio.MaxDirectMemorySize");
 205         if (s == null || s.isEmpty() || s.equals("-1")) {

 206             // -XX:MaxDirectMemorySize not given, take default
 207             directMemory = Runtime.getRuntime().maxMemory();
 208         } else {
 209             long l = Long.parseLong(s);
 210             if (l > -1)
 211                 directMemory = l;

 212         }
 213 
 214         // Check if direct buffers should be page aligned
 215         s = (String)props.remove("sun.nio.PageAlignDirectMemory");
 216         if ("true".equals(s))
 217             pageAlignDirectMemory = true;
 218 
 219         // Remove other private system properties
 220         // used by java.lang.Integer.IntegerCache
 221         props.remove("java.lang.Integer.IntegerCache.high");
 222 
 223         // used by sun.launcher.LauncherHelper
 224         props.remove("sun.java.launcher.diag");
 225 
 226         // used by jdk.internal.loader.ClassLoaders
 227         props.remove("jdk.boot.class.path.append");
 228     }
 229 
 230     // Initialize any miscellaneous operating system settings that need to be
 231     // set for the class libraries.


< prev index next >