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.

Share:
10,214

Related videos on Youtube

ytliu
Author by

ytliu

PhD candidate focus on system security and mobile security

Updated on July 08, 2022

Comments

  • ytliu
    ytliu almost 2 years

    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?

  • Ilia Barahovsky
    Ilia Barahovsky about 8 years
    I believe the link should be source.android.com/devices/tech/dalvik/dalvik-bytecode.html. Look at invoke-kind section.
  • JesusFreke
    JesusFreke about 8 years
    Both 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.