title: Using Java reflection to create eval() method
body: <p>I have a question about reflection
  I am trying to have some kind of eval() method. So i can call for example: </p>
  
  <pre><code>eval("test('woohoo')");
  </code></pre>
  
  <p>Now I understand the there is no eval method in java but there is reflection. I made the following code:</p>
  
  <pre><code>String s = "test";
  Class cl = Class.forName("Main");
  Method method = cl.getMethod(s, String.class);
  method.invoke(null, "woohoo");
  </code></pre>
  
  <p>This works perfectly (of course there is a try, catch block around this code). It runs the test method. However I want to call multiple methods who all have different parameters.</p>
  
  <p>I don't know what parameters these are (so not only String.class). But how is this possible? how 
  can I get the parameter types of a method ?
  I know of the following method:</p>
  
  <pre><code>Class[] parameterTypes = method.getParameterTypes();
  </code></pre>
  
  <p>But that will return the parameterTypes of the method I just selected! with the following statement:</p>
  
  <pre><code>Method method = cl.getMethod(s, String.class);
  </code></pre>
  
  <p>Any help would be appreciated ! </p>