abeln / dotty

Scala with explicit nulls
https://github.com/abeln/dotty/wiki/scala-with-explicit-nulls
Other
23 stars 2 forks source link

Use Checkers Framework annotations for common libraries #8

Open abeln opened 6 years ago

abeln commented 6 years ago

@liufengyun writes

Currently, there are 3 well-known NonNull annotations in the Java world:

A quick github search suggests that Android @NonNull seems to be widely adopted among Android developers.

Kotlin currently supports all known annotations (source):

JetBrains (@Nullable and @NotNull from the org.jetbrains.annotations package)
Android (com.android.annotations and android.support.annotations)
JSR-305 (javax.annotation)
CheckerFramework
FindBugs (edu.umd.cs.findbugs.annotations)
Eclipse (org.eclipse.jdt.annotation)
Lombok (lombok.NonNull).

If the Java source code has no @NonNull annotations, e.g. JDK, can we do better?

Yes. CheckerFramework recently published standard format about external annotation database (.jaif), on August 30th, 2018:

  1. https://checkerframework.org/annotation-file-utilities/
  2. https://checkerframework.org/annotation-file-utilities/annotation-file-format.html
  3. https://github.com/typetools/annotated-libraries

A natural step is to (1) use CheckerFramework inference tools automatically generate annotation databases for Java libraries; (2) grow the databases via crowdsourcing (a more friendly DB interface required). This can be useful for JDK and widely used libraries like Guava, as the APIs are very stable.

liufengyun commented 6 years ago

I don't know how well CheckerFramework performs in nullness annotation inference, they do have the feature:

https://checkerframework.org/manual/#nullness-inference

It would be cool if it can generate a useful set of @NonNull annotations for JDK.