Java注释处理:我怎么知道,如果一个圆是最后一个? [英] Java annotation processing: how do I know if a round is the last one?

查看:274
本文介绍了Java注释处理:我怎么知道,如果一个圆是最后一个?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

延长当 AbstractProcessor ​​,有覆盖的init(...)一种可能性,但没有反其道而行之的方法,这将以后被称为全部轮进行了处理。

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.

使用shutdown钩也不起作用,钩永远不会被调用。

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

任何想法?

推荐答案

的<一个href=\"http://download.oracle.com/javase/6/docs/api/javax/annotation/processing/Processor.html#process%28java.util.Set,%20javax.annotation.processing.RoundEnvironment%29\"><$c$c>Processor.process方法包括类型的参数<一个href=\"http://download.oracle.com/javase/6/docs/api/javax/annotation/processing/RoundEnvironment.html\"><$c$c>RoundEnvironment.也许<一个href=\"http://download.oracle.com/javase/6/docs/api/javax/annotation/processing/RoundEnvironment.html#processingOver%28%29\"><$c$c>RoundEnvironment.processingOver方法能有所帮助。

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

这篇关于Java注释处理:我怎么知道,如果一个圆是最后一个?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
相关文章
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆