Kotlin @JvmStatic functions provided by a default implementation on an interface

Viewed 32

In Kotlin, I can use a @JvmStatic annotation to allow companion object members to be called statically from Java:

Kotlin

class Foo {
    companion object {
        @JvmStatic
        fun bar() {}
    }
}

Java

Foo.bar();

companion object can also implement interfaces:

Kotlin

interface Bar {
    fun bar(){}
}

class Foo {
    companion object : Bar
}

But using this approach, I cannot call bar statically in Java:

Java

Foo.bar(); // error
Foo.Companion.bar(); // OK

Is there a way to provide a @JvmStatic function that is provided by a default implementation on an interface?

0 Answers
Related