title: Java annotation processing with ASM
body: <h2>I want to do some annotation processing (serialization):</h2>
  
  <p><strong>What I want</strong>:</p>
  
  <ul>
  <li>I dont want to subclass the classes in question</li>
  <li>I want to <em>insert</em> a method into an existing class</li>
  <li>I want to use <a href="http://asm.ow2.org" rel="nofollow">ASM</a> to add these methods</li>
  <li>I dont want to generate them <em>by hand</em>, but automatically on compilation</li>
  </ul>
  
  <p><strong>What I have</strong>:</p>
  
  <ul>
  <li>An annotation :)</li>
  <li>The code to scan and modify a .class file with ASM</li>
  </ul>
  
  <p><strong>The problem</strong>:</p>
  
  <ul>
  <li>I don't know <strong>when</strong> to process the .class files</li>
  <li>As far as I know, the <em>AbstractProcessor</em> approach only allows creating new <strong>source</strong> files</li>
  <li>With ASM, I modify <strong>.class</strong> files, but how can the compiler compile the <strong>.java</strong> files when the method still needs to be created by me?</li>
  </ul>
  
  <p><strong>Ideas</strong>:</p>
  
  <ul>
  <li>Right now, the methods to be added are defined by an interface, but using a superclass, I could have a <em>do-nothing</em> implementation, which I can override in post. However, this robs a lot of flexibility, and still, I don't know how to compile it with javac in one step...</li>
  </ul>
  
  <p>Thank you in advance for any tips, suggestions and solutions,<br>
  Till</p>