<bdo id='HQdXS'></bdo><ul id='HQdXS'></ul>

  • <legend id='HQdXS'><style id='HQdXS'><dir id='HQdXS'><q id='HQdXS'></q></dir></style></legend>

      <small id='HQdXS'></small><noframes id='HQdXS'>

    1. <i id='HQdXS'><tr id='HQdXS'><dt id='HQdXS'><q id='HQdXS'><span id='HQdXS'><b id='HQdXS'><form id='HQdXS'><ins id='HQdXS'></ins><ul id='HQdXS'></ul><sub id='HQdXS'></sub></form><legend id='HQdXS'></legend><bdo id='HQdXS'><pre id='HQdXS'><center id='HQdXS'></center></pre></bdo></b><th id='HQdXS'></th></span></q></dt></tr></i><div id='HQdXS'><tfoot id='HQdXS'></tfoot><dl id='HQdXS'><fieldset id='HQdXS'></fieldset></dl></div>

      <tfoot id='HQdXS'></tfoot>

        JVM 如何确保 System.identityHashCode() 永远不会改变?

        How does the JVM ensure that System.identityHashCode() will never change?(JVM 如何确保 System.identityHashCode() 永远不会改变?)
          • <bdo id='Gaph7'></bdo><ul id='Gaph7'></ul>
              <i id='Gaph7'><tr id='Gaph7'><dt id='Gaph7'><q id='Gaph7'><span id='Gaph7'><b id='Gaph7'><form id='Gaph7'><ins id='Gaph7'></ins><ul id='Gaph7'></ul><sub id='Gaph7'></sub></form><legend id='Gaph7'></legend><bdo id='Gaph7'><pre id='Gaph7'><center id='Gaph7'></center></pre></bdo></b><th id='Gaph7'></th></span></q></dt></tr></i><div id='Gaph7'><tfoot id='Gaph7'></tfoot><dl id='Gaph7'><fieldset id='Gaph7'></fieldset></dl></div>

            1. <small id='Gaph7'></small><noframes id='Gaph7'>

                <legend id='Gaph7'><style id='Gaph7'><dir id='Gaph7'><q id='Gaph7'></q></dir></style></legend>
                    <tbody id='Gaph7'></tbody>
                  <tfoot id='Gaph7'></tfoot>

                • 本文介绍了JVM 如何确保 System.identityHashCode() 永远不会改变?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着跟版网的小编来一起学习吧!

                  问题描述

                  Object.hashCode() 的默认实现通常是对象在内存中的分配地址的一些函数(尽管这不是由 JLS).鉴于 VM 在内存中分流对象,为什么 System.identityHashCode() 返回的值在对象的生命周期内永远不会改变?

                  Typically the default implementation of Object.hashCode() is some function of the allocated address of the object in memory (though this is not mandated by the JLS). Given that the VM shunts objects about in memory, why does the value returned by System.identityHashCode() never change during the object's lifetime?

                  如果是一次性"计算(对象的 hashCode 计算一次并存储在对象头或其他东西中),那么这是否意味着两个对象有可能具有相同的 identityHashCode (如果它们恰好首先分配在内存中的相同地址)?

                  If it is a "one-shot" calculation (the object's hashCode is calculated once and stashed in the object header or something), then does that mean it is possible for two objects to have the same identityHashCode (if they happen to be first allocated at the same address in memory)?

                  推荐答案

                  现代 JVM 将值保存在对象头中.我相信该值通常仅在首次使用时计算,以便将对象分配所花费的时间保持在最低限度(有时低至十几个周期).可以编译通用的 Sun JVM,使所有对象的标识哈希码始终为 1.

                  Modern JVMs save the value in the object header. I believe the value is typically calculated only on first use in order to keep time spent in object allocation to a minimum (sometimes down to as low as a dozen cycles). The common Sun JVM can be compiled so that the identity hash code is always 1 for all objects.

                  多个对象可以具有相同的身份哈希码.这就是哈希码的本质.

                  Multiple objects can have the same identity hash code. That is the nature of hash codes.

                  这篇关于JVM 如何确保 System.identityHashCode() 永远不会改变?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持跟版网!

                  本站部分内容来源互联网,如果有图片或者内容侵犯了您的权益,请联系我们,我们会在确认后第一时间进行删除!

                  相关文档推荐

                  Bytecode features not available in the Java language(Java 语言中不可用的字节码功能)
                  ClassCastException because of classloaders?(ClassCastException 因为类加载器?)
                  How can I add a Javaagent to a JVM without stopping the JVM?(如何在不停止 JVM 的情况下将 Javaagent 添加到 JVM?)
                  Cannot load 64-bit SWT libraries on 32-bit JVM ( replacing SWT file )(无法在 32 位 JVM 上加载 64 位 SWT 库(替换 SWT 文件))
                  Encourage the JVM to GC rather than grow the heap?(鼓励 JVM 进行 GC 而不是增加堆?)
                  Why a sawtooth shaped graph?(为什么是锯齿形图形?)

                  1. <tfoot id='eZEdd'></tfoot>
                      <tbody id='eZEdd'></tbody>

                  2. <small id='eZEdd'></small><noframes id='eZEdd'>

                      <i id='eZEdd'><tr id='eZEdd'><dt id='eZEdd'><q id='eZEdd'><span id='eZEdd'><b id='eZEdd'><form id='eZEdd'><ins id='eZEdd'></ins><ul id='eZEdd'></ul><sub id='eZEdd'></sub></form><legend id='eZEdd'></legend><bdo id='eZEdd'><pre id='eZEdd'><center id='eZEdd'></center></pre></bdo></b><th id='eZEdd'></th></span></q></dt></tr></i><div id='eZEdd'><tfoot id='eZEdd'></tfoot><dl id='eZEdd'><fieldset id='eZEdd'></fieldset></dl></div>
                        <bdo id='eZEdd'></bdo><ul id='eZEdd'></ul>
                          <legend id='eZEdd'><style id='eZEdd'><dir id='eZEdd'><q id='eZEdd'></q></dir></style></legend>