自 Lambda 为 Java 发布以来,我想已经过去了 5 年了。
public static void main(String[] args) {
go();
}
private static void go() {
Set<String> set = new HashSet<>();
set.stream().forEach((s) -> {
inner(s);
});
}
private static void inner(String s) {
inner1(s);
}
private static void inner1(String s) {
}
当我在 inner1
上按 CTRL-ALT-H -(打开调用层次结构)时方法,我希望看到 inner1
中的整个堆栈跟踪至main
方法。相反,我的 staktrace 被修剪为 inner
方法。我刚刚下载了最新的 Eclipse,我认为是 2018-12,之前我使用的是 Mars。
Intellij 可以向我显示预期的调用层次结构,但我不太明白为什么 Eclipse 仍然无法做到这一点。不确定 2019 年是否还有其他人在使用 Eclipse,但也许您可以建议一个插件或其他东西。
切换到 Intellij 不是一个选择,我尝试了几次,但这个习惯很难克服。
更新
有类似的-SO question
At run time, evaluation of a lambda expression is similar to evaluation of a class instance creation expression, insofar as normal completion produces a reference to an object. Evaluation of a lambda expression is distinct from execution of the lambda body.
和
Just note, that for lambdas implementing library types like Consumer, the number of callers into accept(T) in a workspace may easily become unmanageable, similar to any call hierarchy through, e.g, Runnable.run() - but that doesn't question the general usefulness of call hierarchies through lambdas.
我并不真正关心 lambda 内部结构,不知何故其他 IDE 能够显示预期的堆栈跟踪
最佳答案
现有 old bug对于 eclipse,2016 年报道,仍处于 NEW 状态
Bug 498498 - [1.8][search][call hierarchy] No usage for lambdas
Call hierarchy on bar method correctly shows usage in accept, and for accept there is no usage shown. This issue was already present in mars.
已有3票修复,可以vote也是
从您编辑的链接中可以看到 another relevant old bug处于新状态
Bug 468561 - [search]Call Hierarchy stops searching in doubly-nested lambda chain
也有 3 票...
关于Eclipse 调用层次结构 lambda,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/55087055/