I'm working on performance monitoring system, which could inject its routines into existing assembly. For that, I'm trying to understand how dalvik code works.
Here's an illustration of what I'm trying to accomplish. Input class could look like this:
class MyClass{
public MyClass(__params__){
//initialization code
}
}
I want to add code for the class to look like this:
class MyClass{
public MyClass(__params__){
this(_params__,0);
//tracking and performance initialization code
}
public MyClass(__params__, int init){
//old initialization code
}
}
What was causing most bugs so far is the distinction between invoke-direct
and invoke-virtual
when calling one constructor from another.
When calling methods, this is straightforward (if method is private, it's called with invoke-direct
, otherwise invoke-virtual
). This doesn't seem to be the case for constructors.
What are the rules of calling invoke-direct
vsinvoke-virtual
when invoking one constructor from another?