title: invoke-virtual vs invoke-direct in constructors
body: <p>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.</p>
  
  <p>Here's an illustration of what I'm trying to accomplish. Input class could look like this: </p>
  
  <pre><code>class MyClass{
      public MyClass(__params__){
          //initialization code
      }
  }
  </code></pre>
  
  <p>I want to add code for the class to look like this:</p>
  
  <pre><code>class MyClass{
      public MyClass(__params__){
          this(_params__,0);
          //tracking and performance initialization code
      }
  
      public MyClass(__params__, int init){
          //old initialization code
      }
  }
  </code></pre>
  
  <p>What was causing most bugs so far is the distinction between <code>invoke-direct</code> and <code>invoke-virtual</code> when calling one constructor from another.</p>
  
  <p>When calling methods, this is straightforward (if method is private, it's called with <code>invoke-direct</code>, otherwise <code>invoke-virtual</code>). This doesn't seem to be the case for constructors.</p>
  
  <p>What are the rules of calling <code>invoke-direct</code> vs<code>invoke-virtual</code> when invoking one constructor from another?</p>