methodIdx
is generally the "method reference index".
It's an index into the method_ids
table, described in the file format docs. The index is relative to a single DEX file, which is why functions like dvmResolveMethod()
take the referring class as well as the method reference index. It's mentioned in the invoke-kind
explanation in the Dalvik bytecode doc.
Each method_id_item
identifies a method by the class in which it was defined, and the function's prototype (name, arguments, return type). There is one method_id_item
for every method declared in or referenced from a DEX file. The indices are established when the DEX file is generated by dx
.
So... methodIdx
gets you to a table entry with a bunch of strings. From there a symbolic lookup gets you to the actual method implementation, i.e. Method*
. See dvmResolveMethod()
in dalvik/vm/oo/Resolve.cpp for the details.
Because the invoke
instructions only have room for a 16-bit method reference index, you can't refer to more than 65535 methods in a single DEX file. (This is a well known problem.)