Demand assumptions: There are methods in packet getKey com.zhoutao.controller () method, the JavaEE, obtained by the process of Method AOP objects, the method getName by now the object, only the results obtained only getKey now what I need is com.zhoutao.controller.getKay then how to get it?
Find the official API did not find this method, now we will look at to analyze the class and method names separately:
Results = Full class name + "." Method name +
Now we've got the method name, and then see if we can find the class of this approach, we look at the source code Method:
public final class Method extends Executable { private Class<?> clazz; private int slot; // This is guaranteed to be interned by the VM in the 1.4 // reflection implementation private String name; private Class<?> returnType; private Class<?>[] parameterTypes; private Class<?>[] exceptionTypes; private int modifiers; // Generics and annotations support private transient String signature; // generic info repository; lazily initialized private transient MethodRepository genericInfo; private byte[] annotations; private byte[] parameterAnnotations; private byte[] annotationDefault; private volatile MethodAccessor methodAccessor; .....
Can be seen through the source code, provides internal clazz, we know by clazz can get the class name, but this clazz is private, how do we get it?
Fortunately, we found the following method can be seen through the source code, provides internal clazz, we know by clazz can get the class name, but this clazz is private, how do we get it?
Fortunately, we found the following:
/** * {@inheritDoc} */ @Override public Class<?> getDeclaringClass() { return clazz; }
Results = Full class name + "." + Method name Results = method.getDeclaringClass (). GetName () + "." + Method.getName ()
Transfer: https://www.jianshu.com/p/2eaed4c0fa0c