views:

354

answers:

2

I'm considering the use of JiBX for a project that will have to run on both Blackberry and RIM. While it seems like J2ME use of JiBX has been considered by the community (as per JiBX jira tickets), Android is relatively new.

The question is, therefore, this: has anybody had any success (or issues, for that matter) using JiBX on Android, or any other libraries that need to modify your class bytecode at build-time?

There have been discussions out there about how such libs should be runnable on Android (as compared to those using runtime bytecode instrumentation), but I haven't seen too many reports about people actually attempting to do this.

+2  A: 

It will not work since android doesn't execute bytecodes. Android's java runtime uses a register based virtual machine (Dvalik) that executes .dex files instead of class files. In theory you could generate those instead of java bytecodes.

hacken
while Dalvik does run special bytecode format, .dex, there is a google-provided tool called dx which converts standard java bytecode into .dex format (look <a href="http://developer.android.com/guide/developing/tools/othertools.html">here</a>).Therefore, theoretically, any lib that does post-compile build-time bytecode manipulation, producing standard-compiant java bytecode, would still work for android -- the dx tool just converts whatever the resulting bytecode is to .dex.
Paul Milovanov
A: 

Ok, so I've decided to just write xml parsing code on top of XMLPull api, without any fancy tricks.

If my schemas get any more complicated than they currently are (and I have time) I'd love to experiment with writing an ANTLR-based XML parser generator to generate actual Java code of the parsers for individual schemas.

At the moment, afaik, java generation for mobile is much safer and better than bytecode-generation for mobile.

Paul Milovanov