码迷,mamicode.com
首页 > 移动开发 > 详细

Android - Warning:Not annotated parameter overrides @NonNull parameter

时间:2014-12-29 23:07:09      阅读:523      评论:0      收藏:0      [点我收藏+]

标签:mystra   android   warning   nonnull   annotation   

Warning:Not annotated parameter overrides @NonNull parameter


本文地址:http://blog.csdn.net/caroline_wendy


Warning:The @NonNull annotation can be used to indicate that a given parameter can not be null.

"@NonNull"的含义是注释非空,如果出现以上警告,就表明参数应该有非空标注;
如添加:
public void onReceive(@NonNull Context context, @NonNull Intent intent);

具体:
It‘s an annotation, but the correct name is NonNull:

protected void onSaveInstanceState(@NonNull Bundle outState)
(And also)
import android.support.annotation.NoNNull;

The purpose is to allow the compiler to warn when certain assumptions are being violated (such as a parameter of a method that should always have a value, as in this particular case, although there are others). From the Support Annotations documentation:

The @NonNull annotation can be used to indicate that a given parameter can not be null.

If a local variable is known to be null (for example because some earlier code checked whether it was null), and you pass that as a parameter to a method where that parameter is marked as @NonNull, the IDE will warn you that you have a potential crash.

They are tools for static analysis. Runtime behavior is not altered at all.






Android - Warning:Not annotated parameter overrides @NonNull parameter

标签:mystra   android   warning   nonnull   annotation   

原文地址:http://blog.csdn.net/caroline_wendy/article/details/42245891

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!