biddyweb / checker-framework

Automatically exported from code.google.com/p/checker-framework
Other
0 stars 1 forks source link

Feature request: recognize android.annotation.Nullable / android.annotation.NonNull #401

Closed GoogleCodeExporter closed 9 years ago

GoogleCodeExporter commented 9 years ago
Similar to Issue 379, but with the framework classes, rather than the support 
library classes.

https://android.googlesource.com/platform/frameworks/base/+/refs/heads/master/co
re/java/android/annotation/Nullable.java
https://android.googlesource.com/platform/frameworks/base/+/refs/heads/master/co
re/java/android/annotation/NonNull.java

Original issue reported on code.google.com by skennedy@google.com on 23 Feb 2015 at 12:40

GoogleCodeExporter commented 9 years ago
Thanks for the heads-up! I've pushed the same fix as for Issue 379:
https://code.google.com/p/checker-framework/source/detail?r=fa82390dac1f3b3a86c6
69a756c20736dbbba4e6

Out of curiosity: is there any guidance on when to use the annotations from the 
two different packages? Why do they have different retention policies?

Original comment by wdi...@gmail.com on 23 Feb 2015 at 5:45

GoogleCodeExporter commented 9 years ago
The android.annotation classes are marked @hide, so third-party apps can't use 
them.

I don't know why they have different retention policies.  It could have to do 
with how the SDK is packaged versus the support library (since that jar is 
included in every app), but I'm not sure.

Original comment by skennedy@google.com on 23 Feb 2015 at 6:01

GoogleCodeExporter commented 9 years ago

Original comment by jtha...@cs.washington.edu on 2 Mar 2015 at 11:57

GoogleCodeExporter commented 9 years ago
I'm not sure if this is related to the retention policy, but 1.8.11 is still 
saying that Activity#onPostCreate() expects a NonNull Bundle.

https://android.googlesource.com/platform/frameworks/base/+/refs/heads/master/co
re/java/android/app/Activity.java clearly shows that it is marked @Nullable.

Should the retention policy be CLASS for these, rather than SOURCE?

Original comment by skennedy@google.com on 4 Mar 2015 at 10:53

GoogleCodeExporter commented 9 years ago
A problem with the annotation on the Activity#onPostCreate() method should not 
be related to the retention policy (and also isn't related to this issue, so we 
should really open a new issue for it).  Where do you expect the annotation to 
be read from?  You can learn about the different ways to annotate libraries, 
and how to debug them, in "Chapter 25  Annotating libraries" of the Checker 
Framework manual:
http://types.cs.washington.edu/checker-framework/current/checker-framework-manua
l.html#annotating-libraries

Original comment by michael.ernst@gmail.com on 5 Mar 2015 at 10:48

GoogleCodeExporter commented 9 years ago
I assume that the point is that in Activity.java, line 1119, onPostCreate is 
annotated with @Nullable.
That @Nullable has retention SOURCE, therefore it is not stored in the jar 
file, making it invisible to the Checker Framework.

The best option is to bring this up with the respective Android developers and 
change that annotation to CLASS retention.

Original comment by wdi...@gmail.com on 6 Mar 2015 at 5:20

GoogleCodeExporter commented 9 years ago
I'm working on a change to Android.  Thanks for your help!

Original comment by skennedy@google.com on 6 Mar 2015 at 5:34