Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Java annotation processing: how do I know if a round is the last one?

When extending AbstractProcessor, there is a possibility to override init(...), but there is no "opposite" method, which would be called after all rounds were processed.

This is a problem: when you have to append information collected during each round to same file, you just can't ever close the file, because you never get to know when the last round was. So, the file is never closed and remains empty.

Using a shutdown hook doesn't work either, the hook is never called.

Any ideas?

like image 853
java.is.for.desktop Avatar asked Nov 10 '10 12:11

java.is.for.desktop


1 Answers

The Processor.process method includes an argument of type RoundEnvironment. Perhaps the RoundEnvironment.processingOver method can be of help.

like image 193
kschneid Avatar answered Oct 05 '22 23:10

kschneid