Where can I find the source code of the android code verifier? I want to work with invokedynamic
s but get some VerifyErrors (java.lang.VerifyError: Verifier rejected class ...
) from the android verifier. My code works using the normal JVM flawlessly, no verification problems, but the android verifier rejects it and I want to analyze why it does that. I can't seem to find the verifier source code online, but it has to be somewhere if it runs on my device.
First off, the JVM and Android use completely different bytecode formats (classfiles and Dex respectively). Although they are similar, they each have different opcodes and encoding methods, and different capabilities and edge cases. There are tools to translate one to the other, but given the differences, you can't always translate everything exactly.
I haven't studied Android bytecode in detail since around 2016, but at the time, there was no support for invokedynamic at all*. Additionally, Android has had numerous verifiers - first there was Dalvik, but then that was too slow, so they moved to ART. They're supposed to be behave similary, but of course, each is an independent code base with its own assortment of bugs. (Incidently, on the JVM side there are also two verifiers, the old inference based verifier and the new stack map verifier, and they also have bugs of their own, though generally not as many due to not evolving as rapidly as Android was).
Anyway, it looks like the ART verifier source code is here.
*Edit: It looks like Android has since added the invoke-custom
opcode, its invokedynamic
equivalent. As with all things Dex, there are subtle differences between the two.