Java reflection: Find fields of a subclass
You have to use getDeclaredFields()
repeatedly on each class in the inheritance hierarchy of your object's class (via getSuperclass()
).
However, what you are planning sounds like a nasty violation of the concept of inheritance. The best way of future-proofing would be to avoid this kind of thing entirely. What are you trying to do that you think requires such reflection shenanigans?