what's the difference between invoke-virtual and invoke-direct in android

ytliu picture ytliu · Jul 19, 2013 · Viewed 9k times · Source

It said that invoke-virtual is invoking the virtual method, while invoke-direct is the direct method.

However I'm not clear what is "virtual method" and what is "direct method"?

In other words, what kind of method invoking will be invoke-virtual and what kind will be invoke-direct?

Can anyone give some concrete example?

Answer

JesusFreke picture JesusFreke · Jul 19, 2013

From http://source.android.com/devices/tech/dalvik/dex-format.html, a direct method is "any of static, private, or constructor".

However, static methods get their own invoke-static opcode, so invoke-direct is used for constructors and private methods.