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

  2. <small id='17UQn'></small><noframes id='17UQn'>

      • <bdo id='17UQn'></bdo><ul id='17UQn'></ul>

      Java中的内联

      Inlining in Java(Java中的内联)
      <tfoot id='5qk1W'></tfoot>

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

              <small id='5qk1W'></small><noframes id='5qk1W'>

                  <tbody id='5qk1W'></tbody>
              • 本文介绍了Java中的内联的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着跟版网的小编来一起学习吧!

                问题描述

                在 C++ 中,我可以声明一个内联"方法,编译器很可能会内联它.据我了解,Java 中没有这样的关键字.

                In C++ I can declare a method "inline" and the compiler is likely to inline it. As far as I understand there is no such keyword in Java.

                如果 JVM 决定这样做,内联是否完成?我能以某种方式影响这个决定吗?

                Inlining is done if the JVM decides to do so? Can I influence this decision somehow?

                推荐答案

                其他几个答案表明只有 final 方法可以内联 - 这不是真的,因为 HotSpot 足够聪明,可以内联非final 方法,只要它们还没有被覆盖.当加载一个覆盖该方法的类时,它可以撤消其优化.显然,使方法最终意味着永远不需要......

                A couple of the other answers have suggested that only final methods can be inlined - this is not true, as HotSpot is smart enough to be able to inline non-final methods so long as they haven't been overridden yet. When a class is loaded which overrides the method, it can undo its optimisation. Obviously making the method final mean that's never required...

                基本上让 JVM 完成它的工作 - 它在确定内联位置方面可能比你要好得多.

                Basically let the JVM do its job - it's likely to be a lot better at working out where to inline than you are.

                您是否有过确信 JVM 做得不好的情况?假设您使用的是 HotSpot,您是否尝试过使用服务器版本而不是客户端?这可以产生巨大的差异.

                Do you have a situation where you're convinced that the JVM isn't doing a good job? Assuming you're using HotSpot, have you tried using the server version instead of client? That can make a huge difference.

                这篇关于Java中的内联的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持跟版网!

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

                相关文档推荐

                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?(为什么是锯齿形图形?)

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

                <tfoot id='D0x2h'></tfoot>

                      <tbody id='D0x2h'></tbody>

                      • <bdo id='D0x2h'></bdo><ul id='D0x2h'></ul>

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