nkiesel
01/31/2020, 3:17 AM.INSTANCE is really not a big deal but so far they are not buying it... Anyone has a better idea?
I have a mixed Kotlin and Java codebase and a singleton in Kotlin with its methods called from Java. The singleton Manager delegates all calls to an implementation of an interface Service (there are multiple possible implementations of Service, Manager picks one at startup). Right now, the code does
object Manager { val delegate = pickImpl(); @JvmStatic fun foo() = delegate.foo(); @JvmStatic fun bar(a: Int) = delegate.bar(a); ... }
and the Java code calls Manager.foo(). This could be simplified to object Manager : Service by pickImpl() but then the Java code has to be changed to call Manager.INSTANCE.foo(). Is there a way to use delegation but retain the @JVMStatic for the Java code?Mike
01/31/2020, 11:52 AM@JvmStatic on the foo function in the Service interface? And discovered it doesn't get 'inherited'?
That's about the only thing I can think of to try.