The original answer of "use Eclipse" is not a bad idea, actually. You could write an Eclipse plug-in which leveraged the Java development tools in Eclipse -- it would work the same way that the various refactorings do. There are plenty of example open-source Eclipse plugins that implement various refactorings, so you can probably find something quite close to what you want and modify it.
Another alternative would be a bytecode-processing library like
Javassist, which lets you read, write, and modify class files directly. You wouldn't have the modified source code then, of course.