Closed JakeWharton closed 7 years ago
Can't get on board with any, sadly. Too much fragmentation in this area.
I've tried to guess why each of the supported nullablilty annotations supported by Kotlin wont work:
org.eclipse.annotations
) not available everywhereorg.jetbrains.annotations
however consists solely of 4 annotations (Mutable
, Nullable
, NonNull
, and ReadOnly
) and is available as a self contained dependency (#604 did not explain why they were not usable either)
Could you explain what you found when you investigated this which prevents using Kotlin's org.jetbrains
annotations?
You nailed most of the reasoning, yep!
The JetBrains ones are okay. We've actually used them in the past. Now that they're fixing their mistake of bundling them inside Kotlin instead of just depending on them they're even more appealing.
I'll bring this up with @swankjesse and see if we can't decide on one because it would likely apply to all our Java projects, not just this one.
I think I’m ready for this. I generally prefer JSR 305 but not well-motivated. JetBrains’ annotations seem reasonable.
Can we assume everything not-annotated is non-null? I’d like to make non-null our default if the tools will honor that.
Then you might want to use @ParametersAreNonnullByDefault
@vanniktech kotlin does not seem to support @ParametersAreNonnullByDefault
at the moment, as noted in a similar issue for OkHttp: https://github.com/square/okhttp/pull/2969#issuecomment-259974936
If you do go with jetbrains for this task, It is worth noting that they have two different versions (org.jetbrains:annotations-java5
and org.jetbrains:annotations
) and could cause hell downstream for people using the opposite of the one you select.
It gives further credence to the interop policy square has been using.
Also the java8 version of it currently breaks autovalue
WIP using org.jetbrains:annotations-java5
: #2290
In general, the disparate nature of these tools depress me. It would be nice to have something assisting with this, however.