title: Any way to further optimize Java reflective method invocation?
body: <p>I am wondering if there are any additional optimizations I can implement to improve the speed of reflective invocations in Java. Not that the performance is prohibitive, but I get the willies when thinking about some piece of code in a library I am writing being implemented in a tight loop somewhere.</p>
  
  <p>Consider a utility method to invoke reflectively:</p>
  
  <pre><code>public static Object invoke(Object targetObject, String methodName, Object[] arguments, Class&lt;?&gt;[] signature)
  </code></pre>
  
  <p>The basic operation is</p>
  
  <pre><code>return method.invoke(targetObject, arguments);
  </code></pre>
  
  <p>As a performance optimization, I cache the method using a hash of the target object's class, method name and signature (the code of which might use some improvement) but beyond that, is there anything else I can do ? I have heard references to some early implementations of <strong>InvokeDynamic</strong> that sound promising, but I just assumed that they were probably not applicable yet, and I discounted my own byte code manipulation as I would like to keep the utility simple (but fast).</p>
  
  <p>Cheers.</p>