KnowledgeHub
Questions
Tags
Users
Search
Alex Rivera
|
Logout
Edit Question
Title
Body
Is it possible to detect if a class is a proxy ( dynamic , cglib or otherwise )? Let classes A and B implement a common interface I . Then I need to define a routine classEquals of signature public boolean classEquals(Class<? extends I> a, Class<? extends I> b); such that it evaluates to true only if a.equals(b) or Proxy(a).equals(b) , where Proxy(a) denotes a dynamic proxy of type A (dynamic, cglib or otherwise). With the assistance of @Jigar Joshi , this is what it looks like so far: public boolean classEquals(Class a, Class b) { if (Proxy.isProxyClass(a)) { return classEquals(a.getSuperclass(), b); } return a.equals(b); } The problem is that it doesn't detect e.g., a CGLIB proxy.
Tags (comma-separated)
Save Edits
Cancel