VM.getSavedProperty和System.getProperty区别

在研究一些源码的时候,会发现,源码中有时会通过VM.getSavedProperty获取一些参数,我们平时写应用时,获取系统参数的时候,通常是使用System.getProperty,那VM.getSavedPropertySystem.getProperty区别是什么呢?

SysteminitializeSystemClass方法中,会初始化系统参数,初始化系统参数的时候:

1、首先获取所有的系统参数放在System
2、有一些可由VM选项控制的系统配置,例如直接内存的最大数量和用于支持自动装箱的对象标识语义的整数缓存大小。 通常,该库将从VM设置的属性中获取这些值。 如果这些属性仅用于内部实现,则应从系统属性中删除这些属性。

private static void initializeSystemClass() {
   
   

        // VM might invoke JNU_NewStringPlatform() to set those encoding
        // sensitive properties (user.home, user.name, boot.class.path, etc.)
        // during "props" initialization, in which it may need access, via
        // System.getProperty(), to the related system encoding property that
        // have been initialized (put into "props") at early stage of the
        // initialization. So make sure the "props" is available at the
        // very beginning of the initialization and all system properties to
        // be put into it directly.
        props = new Properties();
        //初始化系统参数
        initProperties(props);  // initialized by the VM

        // There are certain system configurations that may be controlled by
        // VM options such as the maximum amount of direct memory and
        // Integer cache size used to support the object identity semantics
        // of autoboxing.  Typically, the library will obtain these values
        // from the properties set by the VM.  If the properties are for
        // internal implementation use only, these properties should be
        // remov
评论 3
成就一亿技术人!
拼手气红包6.0元
还能输入1000个字符
 
红包 添加红包
表情包 插入表情
 条评论被折叠 查看
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值