jeudi 21 novembre 2019

Get all private fields of a class (declared and inherited)

I want to scan the annotations (and find some specific one among them) on all fields of a given class, not matter if those fields are private/protected or public, and no matter if they are inherited or not.

Seems there is no way to do this with a single method call to my object's Class. Is that correct?

Why do I think so?

1) getDeclaredFields() returns only declared/own fields
2) getFields() includes inherited fields but does not return private fields

Am I correct? So it seems I have to implement this on my own, it seems.
Say by some recursive approach going all the way up to the top of the
inheritance hierarchy.
Right?





Aucun commentaire:

Enregistrer un commentaire