title: Performance impact of autoboxing
body: <p>Usually the compiler generates code to perform boxing and unboxing. But what does the compiler, if the boxed values are not needed? Is the (Oracle standard) compiler smart enough to optimize it away?</p>
  
  <p>Take a look at this method:</p>
  
  <pre><code>public static void requireInRange(int index, Object[] array) {
      if(index &lt; 0 || index &gt;= array.length)
          throw new IndexOutOfBoundsException();
  }
  </code></pre>
  
  <p>The only relevant information is the <code>array.length</code>, so it would be useless to box each value of an array for example. Like in this code:</p>
  
  <pre><code>int[] anArray = {3, 4, 2};
  requireInRange(3, anArray);
  </code></pre>
  
  <p>Will the compiler actually insert code for boxing each value of the array?</p>