4

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.

Nikhil
  • 16,194
  • 20
  • 64
  • 81
Paul Milovanov
  • 706
  • 4
  • 18

3 Answers3

1

Yes, I have used JiBX to build a prototype in android application. Once you've added jibx jars as your android project library, they will be packaged to dex automatically. In fact, JiBX binding works fine with Android. I only need to include 3 jars. Jibx-run.jar, jibx-ws-0.9-bata.jar and my genereated binding jar. The android application can then make soap client calls, xml to object bindings are handled by jibx internally.

1

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
  • 2,135
  • 11
  • 11
  • 4
    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 here). 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 Jun 09 '09 at 19:40
0

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
  • 706
  • 4
  • 18