robovm icon indicating copy to clipboard operation
robovm copied to clipboard

Is it possible to load additional classes/bundles at runtime?

Open LordTylus opened this issue 5 years ago • 3 comments

Hello there,

I have a general question to loading classes via RoboVM.

Lets say I have a external framework that is not embedded into my RoboVM Projekt so its not compiled on compile time. Is there any way to load it at runtime?

Since RoboVm converts all the Java Sources I should not be able to load any JAR files at runtime since there is no way to compile them then. https://groups.google.com/forum/#!topic/robovm/pceeIuWYF5E

But would it be possible to load any native IOS Bundle that was written and compiled with ObjC at runtime? If so how can I do that?

And If its possible whats the best way to just convert one Jar or .class file to a IOS Bundle?

Also I know that I cannot push my App to the App-Store when loading any code at runtime, since Apples Licensing strictly prohibits it, but I am not aiming to go to the store so that should be fine.

Thanks in advance :-)

LordTylus avatar Oct 10 '18 14:10 LordTylus

Hi, It is possible to load native libraries/framework at runtime, check how Bro.bind does this

It is also possible to convert jar/class into native framework using Framework target. But Framework target is intended to be used to share Java code with native apps and it is bad idea to use RoboVM framework with robovm app itself.

Meanwhile robovm doesn't support generated code splitting to allow functionality you need.

dkimitsa avatar Oct 11 '18 05:10 dkimitsa

Hi,

thank you for the information. This sounds very promising so far.

I have two more questions then. The Bro.bind way looks straight forward, but I am not entirely sure how to get there. I mean usually I would start with something like Class.forName() when loading a class manually. But the Bro.bind example assumes I already have a class Object at hand. Where and how do I get it?

Also the Library which is in the annotation of that class confuses me a little bit. Where does that come from?

Framework target also sounds interesting. I am not planning to run RoboVM from within RoboVM so no worries. I rather plan to run a Micro service or something alike that does the compiling for me. Is there any documentation on how to use Framework target? Or do you know which Methods I have to call exactly for it to do the compiling?

LordTylus avatar Oct 11 '18 07:10 LordTylus

you can't load any new class than were compiled. as compiler makes fixed class list robovm operates with. here is a tutorial for framework target: https://dkimitsa.github.io/2018/01/16/tutorial-writing-framework-improved/

dkimitsa avatar Oct 11 '18 08:10 dkimitsa