How to ignore nullability annotations from java?

Viewed 390

I am using a library that is written and java with @Nonnull and @Nullable annotations on all of the return values and parameters. Unfortunately, the annotations are incorrect in a few places. There is an interface with this method:

interface Expiry<K, V> {
  long expireAfterCreate(@NonNull K key, @NonNull V value, long currentTime);
}

Unfortunately in my case, @NonNull V value can actually be null (since it is a generic type). How can I get Kotlin compiler to ignore the java annotation and allow me to override the method with the proper type:

object Foo : Expiry<String, Bar?> {
  override fun expireAfterCreate(key: String, value: Bar?, currentTime: Long): Long {
    TODO()
  }
}
0 Answers
Related