带有 ? 的对象在 Kotlin 中翻译为 @org.jetbrains.annotations.Nullable in



我有一个用 Kotlin 编写的库。该库包含一个接口,如下所示:

interface IApiRes {
    fun onSuccess(response: Any?)
    fun onError(apiError: ApiError)
}

现在我们的一个客户端是Java,它正在使用这个接口。接口在 java 中正确转换,但是?被翻译成 @org.jetbrains.annotations.Nullable 而不是 @android.support.annotation.Nullable

我知道它们都提供相同的功能,但我仍然希望将我的翻译注释转换为 android.support.annotation.Nullable关于我们如何做到这一点的任何提示?

从 Kotlin 1.2.30 开始,无法控制 Kotlin 编译器使用哪些注释名称。JetBrains 注释是 Kotlin 标准库的一部分,编译器生成的代码仅引用标准库,而不引用任何外部组件。

相关内容

最新更新