In kotlin xxx.kt:
@file:JvmName("Utils")
fun staticFunc()
In java xxx.java:
Utils.staticFunc()
But in java we can't see comment of class Utils because class Utils is not exist(actually it is xxx.kt), How to comment xxx.kt let java user can see comment of class Utils?
This is not supported. The Utils
class does not exist from the Kotlin point of view, it's only produced for JVM interop, so there is no way to provide documentation for it.
If you need to provide documentation to Java callers, use an object
instead:
/**
* My utility functions.
*/
object Utils {
fun staticFunc() { ... }
}
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.