2

Say I have a method m in a class. I'm trying to find all the methods that call m in the whole project. Similar to eclipse's call hierarchy tool, except I need it to output a list/array of Methods. I need it statically so I dont think a stack trace works. Is there any way to implement this, maybe using reflection?

I attached link to an example of Eclipse's call hierarchy tool, finding all the methods that mention the method barking() from the class Dog. (Dog.hungry() and Cat.scratching() call barking()).

Image

4

1 回答 1

1

“标准”java反射可能对此没有任何帮助。

我会尝试使用开源反射库。

您可以通过以下方式搜索方法:

Set<Member> usages = reflections.getMethodUsages(Method.class)
于 2014-10-24T20:13:06.127 回答