I want to find out via reflection if a field is an instance of some type T.
Lets say I have an object o. Now I want to know if it has any fields which are instance of T. I can get all fields with:
o.getClass().getFields();
I can get the type of the field with:
field.getType();
But now I want to know if this type or any supertype equals T. Do I have to call getSuperclass() recursively to be sure to check all supertypes?
You have to use isAssignableFrom.