JSR-269 Annotation Processing
I’ve been contemplating compile time bytecode manipulation for the Object Mapper Framework for a while now. Compile time instrumentation of classes seems to be a better approach and does away a whole lot of class loading issues, especially in OSGI environments. In any case, I remembered Project Lombok and reading about JSR-269, which was introduced with Java 1.6. It’s an API that allows you to plug custom annotation processors into javac.
After experimenting and reading a bit, here is my reading list:
- ZDNet has a good tutorial (Part 2, Part 3)
- JavaBeat tutorial
- Stackoverflow discussion outlines the high level steps very well
- cdivilly helps getting around the paradox situation when you try to build a JSR-269 processor with Maven (long story short: in order for the compiler to pickup the processor, you need a service descriptor in
META-INF/services; however, if you have that file on the Maven classpath, which you usually do in
src/main/resources, the compilerwill try to use the processor it’s supposed to compile… obviously, that won’t work too well)
- dr. macphail has another great tutorial (Part 2, Part 3)
It’s an interesting concept and I got a simple processor to work. Next steps will be to experiment with bytecode weaving/generation and see if I can pregenerate proxies with this.
blog comments powered by Disqus