Java Optimization: (hotspot / Dalvik) optimize the return constant of the final method?

Anyone can tell me whether hotspot or Dalvik is smart enough to inline call the final method that returns the constant (static final) int value? Ideally, method calls will be replaced by constants This may be during class loading or through JIT

This has an impact on the design of some code I am studying

Solution

I think the answer is "no, optimization will not occur because of the lack or existence of final keywords", at least on hotspot VM However, due to other factors, optimization may occur

The following is what Brian Goetz said in this article (for long quotation):

Finally is not final any more, at least in Java 5

The content of this article comes from the network collection of netizens. It is used as a learning reference. The copyright belongs to the original author.
THE END
分享
二维码
< <上一篇
下一篇>>