Type annotations in Android source code

70 views
Skip to first unread message

Dmitry Trunin

unread,
May 25, 2014, 3:08:18 PM5/25/14
to android...@googlegroups.com
Hello

I'm fan of nullness annotations such as defined in JSR 308 and supported by Checker Framework (http://types.cs.washington.edu/checker-framework/).
I use them in my Android application projects and find them very powerful and useful for verifying the correctness of source code and discovering
errors. Now I'm curious about whether developers of AOSP use a kind of nullness annotations in the source code of Android or have plans to use them
in future?

1) Do developers of AOSP use nullness annotations in the source code of Android?
2) Are there any plans to add nullness annotations in future? If yes, this will be type annotations as defined in JSR 308 or other?
3) If there is a contribution which adds type annotations to Android framework classes without changing any runtime properties, will it be accepted?
   Important thing to say about such contributions is that type annotations can be written in comments, so that nothing really changes in runtime
   and the source code can still be compiled by Java 7 compiler.

I believe that if the source code of Android is provided with type annotations, not only this would improve quality of the Android platform itself,
 but also all Android application developers could benefit from this, because information about types from Android Framework can be used to verify
 every Android application by Checker Framework to be free of nullness kind of errors.

Thanks

Sebastian Brestin

unread,
May 27, 2014, 3:13:39 AM5/27/14
to android...@googlegroups.com
When I first read this I wanted to try to implement this on the project that I am working, but after reading the installation process and a few paragraphs of the documentation it seems too intrusive for a old project.


--

---
You received this message because you are subscribed to the Google Groups "Android Contributors" group.
To unsubscribe from this group and stop receiving emails from it, send an email to android-contr...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Sebastian Brestin

unread,
May 27, 2014, 3:16:51 AM5/27/14
to android...@googlegroups.com
I think unit tests are more suitable for code checkings.

Tor Norbye

unread,
May 27, 2014, 11:14:52 AM5/27/14
to android...@googlegroups.com
Yes, in the most recent version of the Android Support Library we included nullness annotations (@NonNull and @Nullable) which you can use in your Android applications. The annotations package includes various other annotations too, such as ones for declaring the expected type of resource int parameters -- and Android Studio includes inspections to ensure that these are used correctly, see http://tools.android.com/recent/androidstudio055released . Studio also enforces nullness both in your own code, as well as in calls to the Android framework.

-- Tor


--
Reply all
Reply to author
Forward
0 new messages