title: Does the Java compiler optimization a method called once by removing the method?
body: <p>Would the java compiler (any mainstream compiler) take something like </p>
  
  <pre><code>void foo () {
      int x = 1;
      System.out.println(x);
  }
  
  void bar() {
      foo()
  }
  </code></pre>
  
  <p>and optimize the foo method away if it is only called in bar resulting in bytecode that would also be generated by this:</p>
  
  <pre><code>void bar() {
      int x = 1;
      System.out.println(x);
  }
  </code></pre>