Another answer.
If I understand your comment correctly, it seems that you have inner classes: Class B (Target) is a class that is defined inside class A. Something like this:
class A { int n; class B { int n; } }
Although these two classes seem to have the same fields, and therefore - should not go into the field where the error was not found - this is not so.
Inner classes (if they are not defined as static) have a hidden field inserted by the compiler. This field refers to the type of the outer class and points to the object that created the inner class object. When using reflection, this field is displayed. Since A does not have such a field, an exception occurs.
source share