Getting a list of accessible methods for a given class via reflection

前端 未结 4 1781
你的背包
你的背包 2020-12-02 20:32

Is there a way to get a list of methods that would be accessible (not necessarily public) by a given class? The code in question will be in a completely different class.

4条回答
  •  我在风中等你
    2020-12-02 21:12

    Pretty sure you will have to walk up the superclasses to get what you want. After all, that's what getMethods() is doing with the getDeclaredMethods() call internally (sort of... it actually calls a private version that filters out non-public methods but it does traverse up the class tree to build the full list).

    Curious why such a thing is needed, though.

提交回复
热议问题