mercredi 2 mars 2016

Reflection: Get fields assigned to other field (java)

So I have multiple fields declared as such:

public interface X{
    int field1 = A.field1 + B.field2 + ... ;
    String fieldS = C.fieldS + D.fieldS + ...;
    ...
}

I'm trying to use reflection to get the fields assigned to field1 and recur on those fields to get the fields assigned to them until I get to the end of the assignments.

If I call getFields(); I get all the fields accessible by the interface but can't tell which are being assigned to my declared fields.

So to reiterate, I have a field and want to get the fields assigned to it. Don't care about the value of the field. The fields being assigned are mostly declared in other classes.

Any help would be greatly appreciated

Thanks.





Aucun commentaire:

Enregistrer un commentaire