java中是否有内联函数? [英] Are there inline functions in java?

查看:560
本文介绍了java中是否有内联函数?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在java中是否有内联函数的概念,或者它取代了其他内容?如果有,它是如何使用的?我听说 public static final 方法是内联函数。我们可以创建自己的内联函数吗?

Is there a concept of inline functions in java, or its replaced something else? If there is, how is it used? I've heard that public, static and final methods are the inline functions. Can we create our own inline function?

推荐答案

在Java中,优化通常在JVM级别完成。在运行时,JVM执行一些复杂分析以确定要内联的方法。它可以在内联方面具有攻击性,而Hotspot JVM实际上可以内联非最终方法。

In Java, the optimizations are usually done at the JVM level. At runtime, the JVM perform some "complicated" analysis to determine which methods to inline. It can be aggressive in inlining, and the Hotspot JVM actually can inline non-final methods.

java编译器几乎从不内联任何方法调用(JVM完成所有这些操作)在运行时)。它们内联编译时间常数(例如最终的静态原始值)。但不是方法。

The java compilers almost never inline any method call (the JVM does all of that at runtime). They do inline compile time constants (e.g. final static primitive values). But not methods.

欲了解更多资源:


  1. 文章:Java HotSpot性能引擎:方法内联示例

Wiki:在OpenJDK中内联,没有完全填充,但包含有用讨论的链接。

Wiki: Inlining in OpenJDK, not fully populated but contains links to useful discussions.

这篇关于java中是否有内联函数?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆