what's the difference between invoke-virtual and invoke-direct in android
10,214
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.
Related videos on Youtube
![ytliu](https://i.stack.imgur.com/YYS0k.jpg?s=256&g=1)
Comments
-
ytliu almost 2 years
It said that
invoke-virtual
is invoking the virtual method, whileinvoke-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 beinvoke-direct
?Can anyone give some concrete example?
-
Ilia Barahovsky about 8 yearsI believe the link should be source.android.com/devices/tech/dalvik/dalvik-bytecode.html. Look at
invoke-kind
section. -
JesusFreke about 8 yearsBoth the old link and new link point to the dex-format.html doc, which contains the quote that I included, in the documentation for the "direct_methods" section. dalvik-bytecode.html also includes similar language in the documentation for invoke-direct.