dimanche 30 avril 2023

Passing Java Function to KFunction

Is there any way way to pass a Function to method with parameters KFunction? I have library in kotlin which I want to make work in java but I'm unable to convert Function to KFunction (?). The function that I want to pass java function

// For example it will be in Event class
fun register(value: KFunction1<Value,Unit>) {
    ...
}

My tries to pass the function to kfunction

public class Test {
    public void launch() {
        Event.register(Test::test); // Error
    }
    @Subscriber
    public static Unit test(Value data) {
        System.out.println("Hello world!");
        return Unit.INSTANCE;
    }
}

PS. I need it to be KFunction due to usage of annotation





Aucun commentaire:

Enregistrer un commentaire