mercredi 20 octobre 2021

j2objc reflection support in native iOS classes

I've just updated my j2objc tool from 1.0.2 to 2.8. As far as I know there were changes in reflection starting from 1.1 version. And now code doesn't work anymore.

We have IApplicationSupport.java interface. Something like this:

public interface IApplicationSupport
{
    void openSupport();
}

This code is successfully translated to Objective-С with j2objc

Then we have platform dependent classes AndroidApplicationSupport and IosApplicationSupport that are not translated. Android part is ok, but iOS has some problems.

Somewhere in code later I need to call [IOSClass classForIosName:@"IosApplicationSupport"]. And that's the problem. I get the next exception every time com.google.j2objc.ReflectionStrippedError: IosApplicationSupport: Reflection is unavailable. Fix this by avoiding reflection or building without --strip-reflection. Of course I do not use --strip-reflection flag during translation (but I believe the problem is not there). Avoid reflection seems to be extremely hard in my case, because there are too much classes with reflection is used.

I understand, that translated classes has rather big __metadata method. Is there any way to emulate metadata for native classes to enable reflection support? If I have to add metadata, are there any rules about how is this generated? Our project is heavy depends on it.

Thanks for any help!





Aucun commentaire:

Enregistrer un commentaire