Is it possible to retrieve lambda expression at runtime

送分小仙女□ 提交于 2019-11-28 13:35:44

You already know that lambda expressions are usually compiled into a synthetic method so you already know which code to decompile to get the lambda’s source code, or, well, something similar to the original code or even something looking completely different, depending on the particular code.

There is no reason why decompiling a lambda expressions should be easier than decompiling any other Java expression. Simple expressions might be easy to recover, especially when the code has debugging information, complex expressions are very likely to look different when decompiling, especially when the compiler applies optimizations to the code.

Andrey Chaschev

You can do this in some cases with Groovy, if this would help you: Getting the contents of closure, in groovy. Geb actually uses this feature to highlight an assertion error inside an evaluated expression.

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!