I want to define a few annotations that will allow extra warnings/errors to be reported during compilation (similar in concept to the @Nullable and @NotNull annotations in IntelliJ).
I would like to be able to write some compiler hooks that will also add my compilation logic based on those attributes.
I want a generic hook if possible, however since we are using Eclipse – it would also be a benefit if we had that ability.
I’d like to know:
- Is it possible? (any of the options above)
- Where do I start?
- I had little experience with annotations so far, so if I’m going about this the wrong way – I’d like to know that and if possible get a better direction to go with.
Thanks.
You can use the Java Annotation Processor (see JSR 269: Pluggable Annotation Processing API) for that. From Annotation checking at compile time with Java Annotation Processor:
The mentioned link provides an example that will get you started.
See also: