如何在编译过程步调试注释处理器? [英] How to step-debug annotation processor during compile?

查看:290
本文介绍了如何在编译过程步调试注释处理器?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有保留策略=源的注解注释处理器。

I have an annotation processor for an annotation of retention policy=SOURCE.

我没有想法如何分步调试。

I have not idea how to step-debug it.


  • 我已经发出打印报表,记录信息,当我运行MVN安装,编译或包或蚂蚁javac和我看到他们sysouts在编译日志中。

  • I have issued print statements, logger info when I run mvn install, compile or package or ant javac, and I see their sysouts in the compile log.

不过,我不知道如何分步在Eclipse中调试处理器。我的意思是,你怎么步调试编译时?

However, I have no idea how to step-debug the processor in Eclipse. I mean, how do you step-debug compile-time?

推荐答案

您必须调用从Eclipse的Java编译器,使用调试配置(您需要手动创建配置,从调试配置... 菜单中选择。

You have to invoke the Java compiler from Eclipse, using a debug configuration (you'll need to create the configuration manually, from the "Debug Configurations..." menu choice.

正确的方式来调用JDK 1.6下的Java编译器或以上是使用的 JavaCompiler的中的 javax.tools 中,你从的 ToolProvider (包括我所有的环节,因为有你应该阅读类/包文档,像样的数目)。

The "correct" way to invoke the Java compiler under JDK 1.6 or above is to use the JavaCompiler interface in javax.tools, which you get from the ToolProvider (I include all the links because there's a decent amount of class/package documentation that you should read).

快速和肮脏的方式(即的工作,但我不作任何保证)是调用 com.sun.tools.javac.Main.main (),向它传递您的正常命令行参数。要做到这一点,你需要的tools.jar 在classpath中(它 $ JAVA_HOME /的发现LIB )。

The "quick-and-dirty" way (that should work, but I make no guarantees) is to invoke com.sun.tools.javac.Main.main(), passing it your normal command-line arguments. To do this, you'll need tools.jar on your classpath (it's found in $JAVA_HOME/lib).

这篇关于如何在编译过程步调试注释处理器?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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