System源码浅析- initializeSystemClass(saveAndRemoveProperties)

前情提要

在前面已经介绍过 System与initializeSystemClass 在此不做过多解释,没有看到的希望去查看!
System源码浅析- initializeSystemClass(initProperties)
System源码浅析- initializeSystemClass(saveAndRemoveProperties)
System源码浅析- initializeSystemClass(setXXX0)
System源码浅析- initializeSystemClass(loadLibrary)
System源码浅析- initializeSystemClass(setup)
System源码浅析- initializeSystemClass( setJavaLangAccess)

saveAndRemoveProperties

描述

        // 某些系统配置可能由 VM 选项控制,例如用于支持自动装箱的对象标识语义的最大直接内存量和整数缓存大小。
        // 通常,库将从 VM 设置的属性中获取这些值。如果属性仅供内部实现使用,
        // 则应从系统属性中删除这些属性。
        //
        // 例如,参见 java.lang.Integer.IntegerCache 和 sun.misc.VM.saveAndRemoveProperties 方法。
        //
        // 保存只能由内部实现访问的系统属性对象的私有副本。删除某些不打算供公众访问的系统属性。

registerNatives

public static void saveAndRemoveProperties(Properties var0) {
    if (booted) {
        throw new IllegalStateException("System initialization has completed");
    } else {
        savedProps.putAll(var0);
        // hashTable的remove(Object key)
        String var1 = (String)var0.remove("sun.nio.MaxDirectMemorySize");
        if (var1 != null) {
            if (var1.equals("-1")) {
                // 返回 Java 虚拟机将尝试使用的最大内存量。如果没有固有限制,则将返回值 {@link java.lang.LongMAX_VALUE}。
                directMemory = Runtime.getRuntime().maxMemory();
            } else {
                long var2 = Long.parseLong(var1);
                if (var2 > -1L) {
                    directMemory = var2;
                }
            }
        }

        var1 = (String)var0.remove("sun.nio.PageAlignDirectMemory");
        if ("true".equals(var1)) {
            pageAlignDirectMemory = true;
        }

        var1 = var0.getProperty("sun.lang.ClassLoader.allowArraySyntax");
        allowArraySyntax = var1 == null ? defaultAllowArraySyntax : Boolean.parseBoolean(var1);
        var0.remove("java.lang.Integer.IntegerCache.high");
        var0.remove("sun.zip.disableMemoryMapping");
        var0.remove("sun.java.launcher.diag");
        var0.remove("sun.cds.enableSharedLookupCache");
    }
}