bsiamionau
bsiamionau

Reputation: 8229

Allow annotation only for specific methods

I've implemented some custom runtime method annotation. Now I want to check (preferably in compile-time) that all methods which were marked with my newly implemented annotation are static and have only one serializable argument. How can I archive it in Java 7?

Upvotes: 0

Views: 640

Answers (1)

Jens Schauder
Jens Schauder

Reputation: 81998

You can use annotation processing to do that. Run javac with proc, processor and processorpath option and implement a Processor that does all the checking you want.

Note that you can't enforce others to use these options, so you should still include appropriate runtime checking.

Upvotes: 1

Related Questions