[英]redundant null check in eclipse kepler
I have following line of code in eclipse kepler. 我在eclipse kepler中有以下代码行。
if (this != null) {
}
This != null
show an error " Redundant null check: this expression cannot be null " even if i have changed Redundant null check into warning by going through Java > Compiler > Errors/Warnings > Null analysis . 此
!= null
显示错误“ 冗余null检查:该表达式不能为null ”,即使我通过Java > 编译器 > 错误/警告 > Null分析将“ 冗余null检查 ”更改为警告。
Considering the following: 考虑以下内容:
this
can only be used inside an instance method , ie in a method which is executed on an existing object. this
只能在实例方法内部使用 ,即在现有对象上执行的方法中使用。 this
refers to the object on which the method is called this
是指在其上调用方法的对象 this
is read-only (cannot explicitly assign null to it for example). this
是只读的 (例如,不能显式分配null)。 Therefore, it is guaranteed that this
is never null. 因此,可以保证
this
是从来没有空。
The compiler warning helps you to identify code which makes no sense or code which is never be executed. 编译器警告可帮助您识别毫无意义的代码或永远不会执行的代码。
EDIT : About error / warning behavior of eclipse kepler, see eclipse-kepler-shows-error-marks-on-warnings 编辑 :关于eclipse kepler的错误/警告行为,请参阅eclipse-kepler-shows-error-marks-on-warnings
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.