title: How is stored the result of the invokedynamic?
body: <p>Java 8 introduces support for first-class functions, which allows assigning functions to variables. In this case the variables must be of a <strong>function type</strong>, which is defined by a <strong>functional interface</strong> (an interface with just one abstract method).</p>
  
  <p>So, considering an example of an interface <code>I</code> and a class <code>A</code> with the following definition:</p>
  
  <pre><code>interface I{ int foo(); }
  class A implements I{ 
    public int foo(){return 7;} 
    public static int bar(){return 11;}
  }
  </code></pre>
  
  <p>We can assign to a variable of type <code>I</code> an instance of <code>A</code> or a <strong>method reference</strong> to the method <code>bar</code> of <code>A</code>. Both can be store on variables of type <code>I</code>,  such as:</p>
  
  <pre><code>I i1 = new A(); 
  I i2 = A::bar;
  </code></pre>
  
  <p>If we analyze the bytecodes resulting from the compilation of the previous code we will get:</p>
  
  <pre><code>0: new           #2                  // class A
  3: dup
  4: invokespecial #3                  // Method A."&lt;init&gt;":()V
  7: astore_1
  8: invokedynamic #4,  0              // InvokeDynamic #0:foo:()LI;
  13: astore_2
  </code></pre>
  
  <p>For <code>i1 = new A();</code> that is clearly that the corresponding instruction <code>7: astore_1</code> is storing an instance of <code>A</code> that is compatible with <code>I</code>. But, as a result of the <code>i2 = A::bar</code> we are storing the result of the <code>8: invokedynamic #4,  0</code>.</p>
  
  <p>So, that means that the result of an <code>invokedynamic</code> is always an instance of the <strong>target type</strong>, which is the type of the variable that we are assigning with a method reference?</p>