I’m interested in doing some tinkering on compiled Class files before they’re converted to dex files by dx. I’ve looked a bit at the official Dalvik documentation and also at comparisons between the DEX format and Class format. I can’t find much information regarding the actual conversion process, class->dex. Does dx first verify the Class files before the conversion? Does it simply go field by field and method by method, merging groups of instructions into more compact groupings? Any insight would be appreciated.
Thanks.
I’m not as familiar with dx itself and the conversion process as with dalvik bytecode, but I don’t recall seeing any verification of the original java bytecode, although obviously it has to be well-formed enough to be parsed/understood by dx.
There is no documentation on the conversion process that I am aware of. It involves converting the bytecode into a couple of intermediate formats (ROP, SSA), and includes some logic for efficient register allocation and some optimizations on the intermediate forms (I think).
For more information on the conversion process, your best bet is to look at the dx source itself (/dalvik/dx)