我想得到调用方法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)
它仅用于测试目的!