如何添加@NotNull注释的运行时处理 [英] How to add run-time processing of @NotNull annotation

查看:900
本文介绍了如何添加@NotNull注释的运行时处理的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我很惊讶地看到IntelliJ在运行/调试单元测试时实际上在IDEA中对@NotNull进行了运行时验证。我可以将这个相同的功能添加到我的maven构建中吗? (我需要什么jar / jvm设置?)

I was quite surprised to see that IntelliJ actually does runtime verification of @NotNull within IDEA when running/debugging a unit test. Is it possible for me to add this same feature to my maven build? (What jars/jvm settings do I require?)

推荐答案

IDEA正在使用自己的检测字节码的方法来添加这样的验证。对于命令行构建,我们提供执行检测的javac2 Ant任务(扩展标准javac任务)。如果从IDEA生成Ant构建,则可以选择使用javac2。

IDEA is using its own method of instrumenting bytecode to add such validations. For command line builds we provide javac2 Ant task that does the instrumentation (extends standard javac task). If you generate Ant build from IDEA, you will have an option to use javac2.

我们还没有提供类似的Maven插件,但有第三方版本可能适合你(虽然,它似乎有点旧)。

We don't provide similar Maven plug-in yet, but there is third-party version which may work for you (though, it seems to be a bit old).

这篇关于如何添加@NotNull注释的运行时处理的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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