Java/Kotlin question about NonNull and primitive a...
# announcements
a
Java/Kotlin question about NonNull and primitive arrays:
Copy code
@Value
public final class Url {
  @NonNull
  private URL url;
  @NonNull 
  private byte[] signature;
}
but in Kotlin it's always treated like
ByteArray!
. Apart from that, NonNull is marked with warning: primitive type members cannot be annotated. Any idea what could be wrong? NonNull annotations are from checker framework.
k
It works for me using the
org.jetbrains.annotations.NotNull
annotation. Maybe you should try the these ones instead https://mvnrepository.com/artifact/org.jetbrains/annotations/17.0.0
a
seems to work with
androidx.annotation.NonNull
too
I tried it with this though:
Copy code
public interface Url {

    @NonNull
    URL getUrl();

    void setUrl(@NonNull URL url);

    @NonNull
    byte[] getSignature();

    void setSignature(@NonNull byte[] signature);

}
assuming it’s what
@Value
would do
k
Given that there is an issue about a similar case, I don’t think that they’re fully respected yet: https://youtrack.jetbrains.com/issue/KT-11456
But I can confirm that it does exactly the same when as you described (both Kotlin and IDE) when using the checker framework, so its most likely very buggy
a
I suppose I can fill an issue then, checker framework annotations are considered to be replacement for findbugs javax.annotation, so