There is a Java method in an external library that I want to invoke from Kotlin, and it accepts a nullable long parameter, but I don’t know how to pass null.
Java:
public static void glfwSetCursor(@NativeType("GLFWwindow *") long window, @NativeType("GLFWcursor *") long cursor) {
cursor is supposed to be nullable, but if I have in Kotlin:
GLFW.glfwSetCursor(window, null)
I get a compilation error: “Null can not be a value of a non-null type Long”
Ok, then it seems to be a mistake in the GLFW docs. Thanks.
It’s been a while since I’ve done any plain Java I wasn’t sure if long i was synonymous for using its wrapper class @Nullable Long i or not.
A quick scratchpad confirms you’re correct, even though you can do Long i = null; and pass i as a long, it’s a NRE.