If you are using reflection and encountering performance problems, the correct approach is pretty much always to write an annotation processor and generate that code instead.

Or generate code without using annotation processor

ReflectASM is the fastest, most general purpose reflection solution. It uses runtime bytecode generation.

https://github.com/EsotericSoftware/reflectasm

When I needed something more custom, I've done the bytecode strategy a few times, using ASM library or equiv. But the cost of change (brittleness, aggravation) is pretty high.

Now I just write Java source and use the JDK's built-in javac to generate the bytecodes.

Some people like StringTemplate. http://www.stringtemplate.org For whatever reason, I still prefer Velocity. Template languages are mostly evil, and variations of terrible, so I just stick to what I know.

Annotations are never the correct answer. For any use case, purpose.

Edit: Whoops. May have spoke too soon. JDK 8's MethodHandle and some other features (inlining simple getters) may have mooted ReflectASM. https://github.com/EsotericSoftware/reflectasm/issues/23 I may have to retool some of my older code.

JavaPoet is a relatively nice library for generating Java sources: https://github.com/square/javapoet