Annotation processing

I’ve been browsing the apt “tutorial” and the com.sun.mirror package and finally figured out how to go through my annotations in my source code. My only question is…how do I generate a new source file with the adjustments caused by the annotations?

For example, I have an interface Inter with one method: method(). I make an annotation @CallFromMethod to mark methods in a class that should be called from that class’ method() method. I make the appropriate AnnotationProcessor and AnnotationProcessorFactory, and I go through all the @CallFromMethod annotations in a source file. How do I change this:


public class SourceTest {

     @CallFromMethod
     public callMe() {
            ...
     }
}

into this:


public class SourceTest implements Inter {

    public callMe() {
           ...
    }

    public void method() {
            callMe();
    }
}

using the apt? I know the example is stupid, but bear with me and please try to help me out.

Thanks in advance!