Reputation: 61
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()).
Upvotes: 3
Views: 2897
Reputation: 14286
The "standard" java reflection will probably not be of any help on this.
I would try using the open source Reflection library.
You can search for a method with via:
Set<Member> usages = reflections.getMethodUsages(Method.class)
Upvotes: 1