How do I get the underlying type of a proxy object in java?

前端 未结 7 1133
旧时难觅i
旧时难觅i 2020-12-09 02:05

I\'d like to access the classname of the underlying class which is an instance of java.lang.reflect.Proxy.

Is this possible?

7条回答
  •  南笙
    南笙 (楼主)
    2020-12-09 02:38

    Simple and robust:

    AopUtils.getTargetClass(object).getName(); 
    

    Will also work for CGLIB proxies and non-proxy objects.

提交回复
热议问题