You can use:
thisObj.getClass().getSuperclass() thisObj.getClass().getInterfaces() thisObj.getClass().getGenericInterfaces() thisObj.getClass().getGenericSuperclass()
I recently coded something to scan class elements, and if they were non-primitive, scan them as well. However, I did not go up, so I did not use the above methods, but I believe that they should do what you want.
EDIT: I checked a simple test with the following:
public class CheckMe { public CheckMe() { } } public class CheckMeToo extends CheckMe { public CheckMeToo() { } }
After that, it is a workaround coding issue. If you parameterize it, then everything can become a little complicated, but still quite feasible.
EDIT: Sorry, did not read carefully, let me look further.
EDIT: There seems to be no way to do this without looking at everything in your CLASSPATH and checking that the object is an instance of some class.
source share