realm / realm-java

Realm is a mobile database: a replacement for SQLite & ORMs
http://realm.io
Apache License 2.0
11.45k stars 1.74k forks source link

Annotation processor should consider RealmObjects that were generated by other annotation processors #4417

Open Zhuinden opened 7 years ago

Zhuinden commented 7 years ago

Currently the processor runs only once, but as multiple rounds are executed, it would be possible to generate RealmProxy classes for RealmObjects that were generated by other annotation processors.

bmeike commented 7 years ago

Yeah. We should do this. I came really close to doing it when I refactored the processor, a few weeks ago, but I didn't understand the impact completely.

cmelchior commented 7 years ago

It is not as trivial as it sounds. I originally investigated that route when doing the initial implementation of modules. There are a few challenges:

The current approach solves both of these constraints quite nicely in the sense that only the DefaultRealmModule must be accessible through reflection. All the other information can then be read through this class including how to find obfuscated model classes.

One solution that comes to my mind could perhaps be to create a RealmDefaultModuleMediator_Round<X> class instead and then combine those at runtime through the CompositeMediatorClass.

Compared to the current approach it would add one extra reflection lookup + handling the associated ClassNotFoundException. That would probably be acceptable, especially considering that we only need minimal changes to do it.

alexmerkle commented 7 years ago

Are there any plans to implement this "minimal" solution in the near future? I just started working with realm and some custom annotation processors. With the ability of generating RealmObjects I could get rid of some boilerplate.