androidormdexmaker

Code injection for Android


I want to write an ORM for Android as my final project. My first idea is to inject code for each get and set. Unfortunately I found a lot of posts saying there is no way to inject code in Android.

On the other hand I found "Dexmaker" to generate code on runtime.

My question is: Is it possible to somehow inject code in Android (by "Dexmaker" or anything else)?

If not how to do it ?

I also thought about reflections but I am afraid that it will be to slow.

Thanks in advance.

Edit

Simon: Yes by ORM I ment object relational mapping. I want to create a general framework. How else I could do this than not by code injection ?


Solution

  • You can inject code using Dexmaker. The project site has a HelloWorldMaker example that generates a class and then loads it.

    You may find the performance of runtime code generation to be unsatisfying however. Projects like Dagger have had better success metaprogramming with code generation.