From the Class#getFields JavaDoc:
Returns an array containing Field objects reflecting all the accessible public fields of the class or interface represented by this Class object.
Maybe your fields are declared as private
or protected
, thus never getting the right number of fields in your class. You should use Class#getDeclaredFields
Returns an array of Field objects reflecting all the fields declared by the class or interface represented by this Class object. This includes public, protected, default (package) access, and private fields, but excludes inherited fields.