This is due to the fact that ByteBuddy (and the JVM in general) does provide good capabilities to instrument lambdas (see here).
Example:
import java.util.ArrayList;
import java.util.function.Consumer;
public class App {
private static Consumer<Integer> method = (n) -> { System.out.println(n); };
public static void main(String[] args) {
ArrayList<Integer> numbers = new ArrayList<Integer>();
numbers.add(5);
numbers.forEach( method );
}
}
$ javac App.java
$ java -javaagent:~/.m2/repository/edu/tum/sse/jtec-agent/0.0.3/jtec-agent-0.0.3.jar=cov.trace=true,cov.level=method App
$ cat 71150_1671108967249_cov.log
{"71150":["App#main([Ljava.lang.String;)void"]}