title: Any way to Invoke a private method?
body: <p>I have a class that uses XML and reflection to return <code>Object</code>s to another class.</p>
  
  <p>Normally these objects are sub fields of an external object, but occasionally it's something I want to generate on the fly. I've tried something like this but to no avail. I believe that's because Java won't allow you to access <code>private</code> methods for reflection.</p>
  
  <pre><code>Element node = outerNode.item(0);
  String methodName = node.getAttribute("method");
  String objectName = node.getAttribute("object");
  
  if ("SomeObject".equals(objectName))
      object = someObject;
  else
      object = this;
  
  method = object.getClass().getMethod(methodName, (Class[]) null);
  </code></pre>
  
  <p>If the method provided is <code>private</code>, it fails with a <code>NoSuchMethodException</code>. I could solve it by making the method <code>public</code>, or making another class to derive it from.</p>
  
  <p>Long story short, I was just wondering if there was a way to access a <code>private</code> method via reflection.</p>