title: Java preprocessor - insert code into every function
body: <p>I am looking for a utility that will allow me to take as input a huge number of .java files (that I am not allowed to modify) and output the same files modified with these changes:</p>
  
  <ol>
  <li>Add an import statement to the top of the file</li>
  <li>In every function matching a certain regex (i.e. <code>* com.foo.*.draw*(*)</code>)...
  <ol>
  <li>Insert <code>Func.begin([function name])</code> at the start of the function, where [function name] is the fully qualified function name (<code>void com.foo.circle.drawLine(int,int)</code>)</li>
  <li>Insert <code>Func.end([function name])</code> at the bottom of the function</li>
  </ol></li>
  </ol>
  
  <p>However, I do not want to use AspectJ for this task because it works with .class files and would potentially slow down things.</p>
  
  <p>Any ideas?</p>