Calling a method with lambda + receiver param from Java

Hi,

is it currently possible to call a Kotlin method which has a lambda parameter with receiver from Java? Something like

fun serviceProxy(init: ServiceProxySpec.() -> Unit)

?

Yes, ServiceProxySpec is the parameter of init.

I don’t quite understand

Calling from Kotlin it would look something like

serviceProxy {
    foo()
    bar()
}

But from Java? How would the call look like? Something like this?

.serviceProxy(s -> s
    s.foo()
    s.bar()
)
FileNameKt.serviceProxy(s -> {
    s.foo();
    s.bar();
    return Unit.INSTANCE;
})
1 Like