Hide static Java methods from Kotlin

谁都会走 提交于 2020-06-25 06:29:26

问题


We're converting a lot of java static methods to kotlin extension functions. However, there are some methods that we need to keep around JUST FOR JAVA (We want to force kotlin code to use the extension functions).

Is there a way to hide java static methods from kotlin?


回答1:


You can annotate those methods with a @Deprecated annotation with deprecation level HIDDEN:

@kotlin.Deprecated(message = "JUST FOR JAVA", level = DeprecationLevel.HIDDEN)
public void foo() {
}



回答2:


There is a solution. It's a bit of a hack, but works perfectly:

@kotlin.SinceKotlin(version = "99999.0")
public void foo() {
}


来源:https://stackoverflow.com/questions/52613604/hide-static-java-methods-from-kotlin

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!