Can you inspect the byte code of a Java 8 lambda at runtime?

后端 未结 4 1956
夕颜
夕颜 2021-01-31 18:22

If you have an anonymous class like

Predicate isEmpty = new Predicate() {
    public boolean test(String t) {
        return t.isEmpt         


        
4条回答
  •  野的像风
    2021-01-31 19:10

    I found another way: by patching the InnerClassLambdaMetafactory it is possible to add an annotation to the lambda classes which points to the implementation method. This is possible at runtime by loading an agent and retransforming the metafactory. See my Blog for details.

提交回复
热议问题