mardi 3 décembre 2019

Java Reflection - Cannot set inherited fields

Class structure is as follows -

    Class A {
       protected String x;
    }

    Class B extends A {
       private String y;
    }

Now I have an object of class B and I want to set the field x using reflection. This is just a dummy use case. I am using reflection here because in the real code there are like around 30 inherited fields that I need to map. Is this possible?





Aucun commentaire:

Enregistrer un commentaire