且构网

分享程序员开发的那些事...
且构网 - 分享程序员编程开发的那些事

IntelliJ IDEA的抱怨为@NotNull参数空检查

更新时间:2021-11-17 00:46:34

如果您使用JetBrains的@NotNull注释,运行时断言将被添加到您的编译后的字节code,它会保证空是没有来过。然后,它真的是没有意义的写在源$ C ​​$ C相同的检查。这种方式工作得很好适合我们。

If you use JetBrains @NotNull annotation, runtime assertions will be added to your compiled bytecode that'll guarantee that null is not passed there. Then it really makes no sense to write the same checks in the source code. This approach works quite well for us.

如果您使用其它注释或只是不想仪字节code,可以禁用通过pressing ALT +这个特殊的警示输入就可以了,编辑检查设置,选中忽略断言声明。这样的条件语句被视为由IDE断言。

If you use other annotations or just don't want to instrument the bytecode, you can disable this particular warning by pressing Alt+Enter on it, "Edit inspection settings" and checking "Ignore assert statements". Such conditional statements are treated as assertions by the IDE.