How can I instantiate a member class through reflection on Android

前端 未结 1 1287
终归单人心
终归单人心 2021-01-23 19:45

I have a saving/loading framework that is supposed to save arbitrary object graphs. This includes instances of non-static nested classes.

Nested classes require are own

相关标签:
1条回答
  • 2021-01-23 20:33

    Okay, turns out I was barking up the wrong tree. The method I've outlined works perfectly well on Android just as well as anywhere else. The problem was that the class I was trying to instantiate in this case was a static internal class. So, while it was a member class, it didn't have a reference to its outer class. I just have to check if (!Modifier.isStatic(objectClass.getModifiers())) before looking for a synthetic constructor/field.

    0 讨论(0)
提交回复
热议问题