Some annotations that could give us performance advantages need to be placed on library code. Rather than add the library code to our code base then annotate it, it seems more desirable to have an annotation phase that transforms .class files to annotated .class files.
For example, java.lang.String.value, a package protected character array, will never vary during runtime. If it work marked as immutable then any loads from it could be simplified away. So "Morrissey".charAt(0) could be simplified to 'M' at compile time.
There are various tools for .class to .class transformations. The most famous being BCEL , which doesn't have annotation support but can be made to . Performing annotations using a Java tool also gives the possibility to use that tool as a java agent to annotated code dynamically.
An alternate approach is to perform annotations in the class loader.