1

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 ?

orwe
  • 233
  • 1
  • 3
  • 10
  • 2
    Do you mean object relational mapping? Or something else? Also, what is it about your design that requires you to use code injection? – Simon Dec 02 '12 at 21:44
  • Relflection under Android is dog slow. That's a non-starter. – Gray Dec 03 '12 at 01:43

1 Answers1

1

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.

Jesse Wilson
  • 39,078
  • 8
  • 121
  • 128