title: Java inline method that contains private calls
body: <p>Assuming that the jvm identifies the b.foo() method as hot, will it try to inline it? Because if it does, the call instruction B.bar() will be inlined in the A.main method, which is prohibited because bar is private. What does the jvm do in these situations?</p>
  
  <p>Any documentation with further details is appreciated as well. Thanks</p>
  
  <pre><code>public class A {
  
      public static void main(String[] args)
      {
          B b = new B();
          for (int i=0; i&lt;99999; i++)
              b.foo();
      }
  }
  
  class B {
  
      public void foo() {
          bar();
      }
  
      private void bar() { // do something. (is small method)
      }
  }
  </code></pre>
  
  <p>EDIT: I'm asking because when i try to do this optimization myself (in bytecode) I get a verify error which makes sense:</p>
  
  <p>java.lang.VerifyError: Bad invokespecial instruction: current class isn't assignable to reference class</p>
  
  <p>EDIT2:</p>
  
  <pre><code>public static void main(java.lang.String[]);
  descriptor: ([Ljava/lang/String;)V
  flags: ACC_PUBLIC, ACC_STATIC
  Code:
    stack=2, locals=5, args_size=1
       0: new           #13                 // class B
       3: dup
       4: invokespecial #14                 // Method B."&lt;init&gt;":()V
       7: astore_1
       8: iconst_0
       9: istore_2
      10: iload_2
      11: ldc           #15                 // int 99999
      13: if_icmpge     30
      16: aload_1
      17: astore        4
      19: aload         4
      21: invokespecial #18                 // Method B.bar:()V // VERIFY ERROR HERE
      24: iinc          2, 1
      27: goto          10
      30: return
    StackMapTable: number_of_entries = 2
      frame_type = 253 /* append */
        offset_delta = 10
        locals = [ class B, int ]
      frame_type = 19 /* same */
    LineNumberTable:
      line 5: 0
      line 6: 8
      line 7: 16
      line 14: 19
      line 15: 24
      line 6: 24
      line 8: 30
  </code></pre>