I have a third party Java library which an object with interface like this:
public interface Handler { void call(C context) throws Exception; } >
The simplest answer probably is the Kotlin's lambda:
val handler = Handler { println("Hello world") } handler.call(myContext) // Prints "Hello world"