samedi 23 novembre 2019

Reflection Class.getDeclaredFields() is not retrieving anything on Android

I have an instance of class android.icu.util.TimeZone which actually instance of android.icu.impl.OlsonTimeZone. I need to retrieve a field of transitions using reflection. But getDeclaredFields retrieves only one static field. How could it be, if during debuging I see lots of fields in this class?

TimeZone tz = TimeZone.getTimeZone("Europe/Kiev");
try {
    Class<?> actionClass = Class.forName(tz.getClass().getName()/*, true, ClassLoader.getSystemClassLoader()*/); // Also have tried with SystemClassLoader
    Field[] allFields = actionClass.getDeclaredFields();
        for (Field field : allFields) {
            Log.d("field:", field.getName());
        }
} catch (ClassNotFoundException e) {
    e.printStackTrace();
}

Instance members

What reflection is retrieved





Aucun commentaire:

Enregistrer un commentaire