16

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?

frogatto
  • 28,539
  • 11
  • 83
  • 129
ytliu
  • 569
  • 1
  • 4
  • 12

1 Answers1

30

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.

frogatto
  • 28,539
  • 11
  • 83
  • 129
JesusFreke
  • 19,784
  • 5
  • 65
  • 68
  • I believe the link should be http://source.android.com/devices/tech/dalvik/dalvik-bytecode.html. Look at `invoke-kind` section. – Ilia Barahovsky Jun 23 '16 at 06:35
  • 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. – JesusFreke Jun 23 '16 at 17:32