vendredi 26 juin 2015

What's the reason for this ART error when using an InvocationHandler to create a Interface via reflection?

I created a proxy using reflection (InvocationHandler) so I can dynamically create and access an Interface via a class that implements it

Example:

class Foo implements ILauncher
class Joo implements ILauncher
(...)
ILauncher launcher1 = (ILauncher) ILauncherProxy.newInstance(Class.forName("Foo").newInstance());
(...)
ILauncher launcher2 = (ILauncher) ILauncherProxy.newInstance(Class.forName("Joo").newInstance());

Fooand Joo have a launch method and other stuff.

I was geting this strange error when invoking the launch method from the interface, but only with one the implementing classes!

06-26 19:54:49.363    8644-8654/XXX E/art﹕ art::mirror::Object*       art::StackVisitor::GetThisObject() const unimplemented Failed to determine this object of abstract or proxy method: void com.mig.filmeshoje.service.launcher.ILauncher.launch(ISynchronizer, IEntityCallback, java.lang.Class, ListWrapper)

Turns out that Joo had one protected member, private members and public methods, whereas Foo only had private members and public methods. When I changed the protected member to private in Joo, the error no longer happens! Can anyone explain this? Is this expected and if so, is there documentation that points to a best practice?





Aucun commentaire:

Enregistrer un commentaire