title: Runtime code generation and compilation
body: <p>Say I have this code that uses some input (e.g. a URL path) to determine which method to run, via reflection:</p>
  
  <pre><code>// init
  map.put("/users/*", "viewUser");
  map.put("/users", "userIndex");
  
  // later
  String methodName = map.get(path);
  Method m = Handler.class.getMethod(methodName, ...);
  m.invoke(handler, ...);
  </code></pre>
  
  <p>This uses reflection so the performance can be improved. It could be done like this:</p>
  
  <pre><code>// init
  map.put("/users/*", new Runnable() { public void run() { handler.viewUser(); } });
  map.put("/users", new Runnable() { public void run() { handler.userIndex(); } });
  
  // later
  Runnable action = map.get(path);
  action.run();
  </code></pre>
  
  <p>But manually creating all those <code>Runnable</code>s like that has its own issues.
  I'm wondering, can I generate them at runtime? So I'd have an input map as in the first example, and would dynamically create the map of the second example.
  Sure, generating it is just a matter of building a string, but what about compiling and loading it?</p>
  
  <p><strong>Note:</strong> I know the performance increase is so little it's a perfect example of premature optimization. This is therefore an academic question, I'm interested in runtime generation and compilation of code.</p>