In Kotlin, the package-level functions are represented as static methods. Also, in Kotlin, you can make static methods for functions that are defined in some companion object or named object by using the @JvmStatic annotation. For example:
// Kotlin object Utils { fun doSomething() { // logic here } }
Now, calling from Kotlin
// calling from Kotlin class Utils.doSomething()
But, when you call this from Java, you get a compilation error.
// calling from Java class Utils.doSomething(); // compilation error
You will have to call like this from Java.
// calling from Java class Utils.INSTANCE.doSomething(); // works fine
How can we make it work without using the INSTANCE?
The answer is JvmStatic.
Our updated Kotlin code:
// Kotlin object Utils { @JvmStatic fun doSomething() { // logic here } }