How to write a Java annotation processor?

This can not be done with a compile time annotation processor. Compile time time annotation processors can only generate new files (and classes) they can not modify existing classes. You can do reflection at runtime but strictly speaking you that is not called annotation processing. Also you won’t have access to local variables.

If you’re looking on how to write a compile time annotation processor check out https://github.com/pellaton/spring-configuration-validation-processor

Leave a Comment