If you look at the JavaDoc of getField()
, you see the problem:
Returns a Field object that reflects the specified public member field of the class or interface represented by this Class object.
You need to use:
Field field = this.getClass().getDeclaredField("criteriaType");
From the JavaDoc ofgetDeclaredField()
:
Returns a Field object that reflects the specified declared field of the class or interface represented by this Class object.
Note that getDeclaredField()
, unlike getField()
, won't find inherited fields.