如果被 Spring 包装到代理中,如何知道原始 class 名称?
How to know original class name if wrapped into proxy by Spring?
我正在尝试通过 getClass().getSimpleName()
在 Spring
下获取一些 classes 名称,它 returns 类似于
MyClass$$EnhancerBySpringCGLIB$$SOMEHEX
这可能是因为 Spring
将 class 包装到代理中。
是否有任何可移植的方法来获取原始 class 名称?
Spring 为此提供了一个实用程序。
public static Class<?> getUserClass(Class<?> clazz)
"Return the user-defined class for the given class: usually simply the given class, but the original class in case of a CGLIB-generated subclass."
我正在尝试通过 getClass().getSimpleName()
在 Spring
下获取一些 classes 名称,它 returns 类似于
MyClass$$EnhancerBySpringCGLIB$$SOMEHEX
这可能是因为 Spring
将 class 包装到代理中。
是否有任何可移植的方法来获取原始 class 名称?
Spring 为此提供了一个实用程序。
public static Class<?> getUserClass(Class<?> clazz)
"Return the user-defined class for the given class: usually simply the given class, but the original class in case of a CGLIB-generated subclass."