inline-method

Inlining in Java

时间秒杀一切 提交于 2019-11-26 04:26:00
问题 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. Inlining is done if the JVM decides to do so? Can I influence this decision somehow? 回答1: 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,