在转换 Java 8 access private member with lambda? 时来自 concrete format至 generic format我找到了 another limitation :
To issue a complete symbolic type descriptor, the compiler must also determine the return type. This is based on a cast on the method invocation expression, if there is one, or else Object if the invocation is an expression or else void if the invocation is a statement.
我很好奇是否有办法overcome this ?
最佳答案
如果您的编译时调用签名与您传递给LambdaMetafactory
。它将执行所需的转换。
对于 lambda 实例方法的实际调用,没有性能损失。在返回封装了 MethodHandle
的 CallSite
之前,LambdaMetafactory
决定生成的 lambda 将如何工作。因此,您调用它来构建 lambda 实例的方式不会影响结果。
关于Java 8 通用 LambdaMetafactory?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/28196829/