This is actually really easy to prove. Here is a very simple code:
for (int i = 0; i < 100_000; ++i) { Stream.of(1, 2, 3, 4) .map(x -> x * 2) .collect(Collectors.toList()); }
When I compile this, I see that the generated de-sugared method (via javap ) for the lambda expression is called: lambda$main$0 (in jdk-9, but that doesn't really matter).
And then I can just run this code with:
java -XX:-TieredCompilation -XX:CICompilerCount=1 -XX:+UnlockDiagnosticVMOptions -XX:+PrintCompilation -XX:+PrintInlining -XX:CompileCommand="print, *.lambda" InlineLambdaTest > inline.txt
And looking at the file, there are lines like this:
Inline::lambda$main$0 (10 bytes) inline (hot)
Thus, inlay for such a method works in the usual way. Note that there will be more lines starting with ...lambda... since there are many other places inside that use a lambda expression that are also considered hot.
source share