问题
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