Can HotSpot inline lambda function calls?
问题 Considering the code: someList.forEach(x -> System.out.format("element %s", x)); Theoretically, it should be possible to inline this code and eliminate the indirect function calls by first inlining the forEach method, and then inlining the lambda function body in the inlined forEach code. Is HotSpot capable of performing this optimization? What restrictions govern whether or not it is performed in a particular situation? 回答1: Your lambda expression is compiled into an ordinary method, while