So I have an annotation that, although it can be declared multiple times, generally needs to access the same properties file. Currently I am using a static registry in my annotation processor to track if the file has been created, and to store the writer for the file. So far this works fine, but my problem is figuring out when to save the file. Currently I am making a call to roundEnv.processingFinished (or whatever that method is) at the end of my annotation processor, and if it returns true I save the file. The problem I am having is that, if source fines are generated, and the compiler goes into a new round of processing that does not contain any of my annotation, the file will not ne saved. I was thinking about adding an entirely new processing that supports every annotation, but claims none, and making the check there. I just feel like this is a slightly clunky option, especially since the spec indicates a processor should only support annotations it will actually process. Is there some better way of doing this, or should I just go with the additional processor model?
Asked
Active
Viewed 78 times
0
-
It's not really clear what you asking. You may want to post the relevant part(s) of your code to illustrate the problem. – PM 77-1 Jan 21 '16 at 02:43
-
Have you actually witnessed this behavior? Reading the docs, it appears that what you've described should work. Specifically, "If a processor was asked to process on a given round, it will be asked to process on subsequent rounds, including the last round, even if there are no annotations for it to process." from the `javax.annotation.processing.Processor` javadoc. Perhaps if you shared your code someone might be able to pinpoint why you're not seeing the behavior that you're expecting. – jbunting Jan 21 '16 at 04:35