相关疑难解决方法(0)

获取调用方法(java.lang.reflect.Method)

我想得到调用方法java.lang.reflect.Method.不是方法的名称.

以下是如何获取调用者类的示例.

// find the callers class
Thread t = Thread.getCurrentThread();
Class<?> klass = Class.forName(t.getStackTrace()[2].getClassName());
// do something with the class (like processing its annotations)
... 
Run Code Online (Sandbox Code Playgroud)

它仅用于测试目的!

java reflection

16
推荐指数
2
解决办法
1万
查看次数

标签 统计

java ×1

reflection ×1