Q:

How Kotlin infers Java method parameter nullability?

I'm trying to call Java method org.springframework.data.mongodb.core.query.Update#set from Kotlin code. This method is declared as
public Update set(String key, Object value)

There is no additional annotations or comments about parameters nullability. In fact, it just puts value into HashMap, so effectively value might be null.
However, Kotlin compiler treats value type as Any (instead of expected Any!), and fails when passing null with
Null can not be a value of a non-null type Any

Passing nullable value with !! patently causes KotlinNullPointerException, casting as Any throws TypeCastException.
What is the logic behind such nullability inference? Passing null parameter with reflection actually works well, but is there more natural solution? 

A:

This is caused by the annotation in the package's package-info.java:
@org.springframework.lang.NonNullApi
package org.springframework.data.mongodb.core.query;

which is

A common Spring annotation to declare that parameters and return values are to be considered as non-nullable by default for a given package... used by Kotlin to infer nullability of Spring API

