Pergunta

I am trying to generate a call graph based on .smali file. However, I encountered a confusing case as follow:

.super Landroid/graphics/drawable/Drawable;
.source "SBarExp.java"

.method public final setBounds(Landroid/graphics/Rect;)V
  .line 514
  iget-object v2, p0, Lcom/sds/android/ttpod/app/modules/skin/view/SeekBarExpansion$a;->b:Landroid/graphics/drawable/Drawable;
  invoke-virtual {v2, p1, v0, p3, v1}, Landroid/graphics/drawable/Drawable;->setBounds(IIII)V
  .line 515
  invoke-super {p0, p1, v0, p3, v1}, Landroid/graphics/drawable/Drawable;->setBounds(IIII)V
.end method

Based on my understanding, invoke-super simply means it is going to call a parent method, so

invoke-super {p0, p1, v0, p3, v1}, Landroid/graphics/drawable/Drawable;->setBounds(IIII)V can be interpreted as Landroid/graphics/drawable/Drawable;->setBounds(IIII)V ?

If yes, I would like to know if invoke-virtual {v2, p1, v0, p3, v1}, Landroid/graphics/drawable/Drawable;->setBounds(IIII)V is the same as invoke-super {p0, p1, v0, p3, v1}, Landroid/graphics/drawable/Drawable;->setBounds(IIII)V?

If not, what is the difference? If yes, why is it invoking the same method twice (using different ways)?

Please help, many thanks!

Foi útil?

Solução

invoke-virtual performs a virtual table lookup using the vtable associated with the target object's class (i.e. the actual runtime type of the first argument).

However, invoke-super is slightly different. It performs a vtable lookup using the superclass of the class containing the method being executed. In particular, note that the vtable lookup does not use or depend on the runtime type of the target object.

In your example, the invoke-virtual instruction is being called on the result of

iget-object v2, p0, Lcom/sds/android/ttpod/app/modules/skin/view/SeekBarExpansion$a;->b:Landroid/graphics/drawable/Drawable;

At this point, the actual method that is called depends on the actual type of v2, which could be any subclass of Drawable.

The invoke-super instruction is being called on the p0 register, which likely contains the "this" reference for the current object. However, the runtime type of p0 doesn't actually matter. The invoke-super instruction will always call Drawable's implementation of setBounds, regardless of the runtime type of p0.

Licenciado em: CC-BY-SA com atribuição
Não afiliado a StackOverflow
scroll top