Java: How will JVM optimise the call to a void and empty function?

前端 未结 6 910
囚心锁ツ
囚心锁ツ 2020-12-15 23:35

Let\'s imagine we have the following classes:

public class Message extends Object {}

public class Logger implements ILogger {
 public void log(Message m) {/         


        
6条回答
  •  遥遥无期
    2020-12-16 00:17

    Probably eventually, definitely not immediately, and not necessarily ever. The JIT makes no guarantees, especially not for a method that only gets called a couple times. (It would probably get categorized as simply inlining the log call, and the inlined code happening to be...nothing.)

提交回复
热议问题